Bug #15937 [Opn]: Expect header sent for some versions of curl by default can not be unsetted
| From: | daniel dot oconnor at gmail dot com | Date: | Sun, 01 Mar 2009 22:35:09 +0000 |
| Subject: | Bug #15937 [Opn]: Expect header sent for some versions of curl by default can not be unsetted | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-95@lists.php.net to get a copy of this message | ||
Edit report at http://pear.php.net/bugs/bug.php?id=15937&edit=1
ID: 15937
Updated by: daniel.oconnor@gmail.com
Reported By: kase at gmx dot net
Summary: Expect header sent for some versions of curl by
default can not be unsetted
Status: Open
Type: Bug
Package: HTTP_Request2
PHP Version: 5.2.0
Roadmap Versions:
New Comment:
Would this affect any of the other drivers?
Previous Comments:
------------------------------------------------------------------------
[2009-02-24 14:30:38] kase
Description:
------------
Hi Alexey,
some versions of curl send the Expect header for a post request by
default. Some webservers (e.g. Lighttpd) can not handle this header and
send a "417 Expectation Failed" back.
To disable the default expect header, you have to set it to an empty
string. (see *1 and *2).
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
This is not possible at the moment with the Request2 package, because
if you set $request->setHeader('Expect', '') it will be unset from the
headers array, so curl sends the header again by default.
Can you implement an option to configure the expect header for
curl-adapter, or allow setting an empty header to the setHeader
function?
*1:
http://www.shoemoney.com/2008/12/29/lib-curl-twitter-api-expect-100-continue-pain-and-how-to-fix-it/
*2: http://redmine.lighttpd.net/issues/1017#note-17
Thanks!
Test script:
---------------
For a curl version sending NO expect header by default (to reproduce)
$request = new HttpRequest('http://sourceforge.net/');
$request->setHeader('Expect', '100-Continue');
$request->setMethod('POST');
$request->addPostParameter('a', 'b');
$response = $request->send();
print_r($response->getStatus());
Fix for a curl version (e.g. 7.15.*, debian etch) sending expect header
by default
$request = new HttpRequest('http://sourceforge.net/');
$request->setHeader('Expect', '');
$request->setMethod('POST');
$request->addPostParameter('a', 'b');
$response = $request->send();
print_r($response->getStatus());
Expected result:
----------------
417
200
Actual result:
--------------
417
417
------------------------------------------------------------------------
--
Edit this bug report at http://pear.php.net/bugs/bug.php?id=15937&edit=1