public
Created

Workaround in PHP cURL for the 100-continue expectation

  • Download Gist
gistfile1.aw
PHP
1 2 3 4 5 6 7 8 9 10
<?php
// cURL obeys the RFCs as it should. Meaning that for a HTTP/1.1 backend if the POST size is above 1024 bytes
// cURL sends a 'Expect: 100-continue' header. The server acknowledges and sends back the '100' status code.
// cuRL then sends the request body. This is proper behaviour. Nginx supports this header.
 
// This allows to work around servers that do not support that header.
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
 
// We're emptying the 'Expect' header, saying to the server: please accept the body right now.
// Read here: http://pilif.github.com/2007/02/the-return-of-except-100-continue/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.