Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: Switch to HTTP1.1? #22

Open
TrueType opened this issue Jan 24, 2016 · 1 comment
Open

TODO: Switch to HTTP1.1? #22

TrueType opened this issue Jan 24, 2016 · 1 comment

Comments

@TrueType
Copy link

I put this up as I encountered a web page, whos content was sliced into chunks. This comes with HTTP/1.1 and its header "Transfer-Encoding: chunked". The chunks start with a hexadecimal number for their size and a "0" for the last chunk. With "echo $this->get(..);" you will see them. Chunks and HTTP/1.1 is a general behaviour these days.

Simpletest uses "GET /mypage.php HTTP/1.0" in http.php telling a server it will not understand the "Transfer-Encoding: chunked" header. That is why I should NOT have seen any chunked content.

I tested with 5 servers today. Two of them sent me chunked content. As I am not into (Apache) server configuration I cannot say much to why it was not handled.
https://httpd.apache.org/docs/2.2/de/env.html
One can always set the "Content-Lenght: 1234" header in the application itself, which whould prevent servers (e.g. Apache) from chunking.

Another way is to enable Simpletest to handle HTTP/1.1 protocol. That may be more an effort than just the chunked content. Here is some info about how much work it is to dechunk:
http://stackoverflow.com/questions/10793017/how-to-easily-decode-http-chunked-encoded-string-when-making-raw-http-request

I guess in the very long run Simplettest cannot stay with HTTP/1.0. So its about selecting information already about how to go that way.

@jakoch
Copy link
Member

jakoch commented Jan 24, 2016

Hey Henri,

ok, lets see..
HTTP/1.0 is hardcoded in getRequestLine()
https://github.com/simpletest/simpletest/blob/master/http.php#L41

So, yes, http.php specifies HTTP/1.0 instead of HTTP/1.1, so you won't get a chunked response.

Then getRequestLine() is used to append the properties of the created Socket, which is a SimpleSocket.
https://github.com/simpletest/simpletest/blob/master/http.php#L79

I'm not sure, if we can override it by setting an additional header.
You are right, in the long run, we need to change this to 1.1 and
adjust the Socket class to evaluate the return header ['transfer-encoding'] == 'chunked'
and handle and return the chunked content properly.
Kind of re-assembling or glueing the stream of chunked data into a whole piece again.
The function from SO is helpful. Thank you for that.

Best, Jens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants