php-http / curl-client

cURL client
http://httplug.io
MIT License
443 stars 28 forks source link

Invalid "Expect" header #18

Closed fyfey closed 8 years ago

fyfey commented 8 years ago

I would like to add the ability to handle a 100-continue status from the server as I just hit a bug where I would get the following response:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK
Date: Tue, 08 Mar 2016 10:34:43 GMT
Server: Apache/2.2.22 (Debian)
X-Powered-By: PHP/5.4.45-0+deb7u2
etc

It gets the initial header line and then throws an exception parsing HTTP/1.1 200 OK as a header due to the missing colon.

I fixed it by setting an empty "Expect" header. Somewhere an "Expect 100-continue" was being added to my request (I wasn't explicitly setting this).

Could we check the initial status line for this status, and then discard the first 2 lines and resume parsing the actual response?

mekras commented 8 years ago

The problem is that cURL sends the header "Expect: 100-continue" by default. But curl-client does not support the "Expect-Continue" mechanism. I'll suppress "Expect" header to resolve this bug. And if you need support for "Expect-Continue", please, create a separate issue for it.

mekras commented 8 years ago

Please, try this Client.php

fyfey commented 8 years ago

Thanks mekras, I've just deployed the new Client and will let you know how testing goes

fyfey commented 8 years ago

This has indeed resolved the problems we were having. Thanks for the quick response!

mekras commented 8 years ago

Fixed in version 1.3.