Sunday, 15 August 2010

php - How can I stream a GET request line-by-line? -



php - How can I stream a GET request line-by-line? -

i send request server streamed in 'realtime' using chunk transfer encoding can completley modify line-by-line. example:

sendchunks = somehttplibrary.senddata; sendchunks(example.org, "5\r\n") sendchunks(example.org, "hello\r\n") sendchunks(example.org, "7\r\n") sendchunks(example.org, "goodbye\r\n") sendchunks(example.org, "0\r\n")

where right now, don't care listening response. doesn't need in c++, i'm comfortable python, javascript, php or similar.

firstly, shouldn't sending request body along request. think technically can, if server it's non-compliant. see http://stackoverflow.com/a/983458/241294.

from question looks though know need chunked transfer encoding. here rough illustration of how can accomplish in python, post request instead of get request (code hacked here):

import httplib conn = httplib.httpconnection('example.org') conn.connect() conn.putrequest('post', '/post') conn.putheader('transfer-encoding', 'chunked') conn.endheaders() conn.send("5\r\n") conn.send("hello\r\n") conn.send("7\r\n") conn.send("goodbye\r\n") conn.send("0\r\n") resp = conn.getresponse() print(resp.status, resp.reason, resp.read()) conn.close()

for nicer illustration python chunking function see how forcefulness http.client send chunked-encoding http body in python?.

php c++ http stream request

No comments:

Post a Comment