PHP and cURL: Disabling 100-continue header

Published June 15th, 2006

I’ve been using cURL (through PHP) to build a sort of proxy for a project I’m working on. I need to parse the returned headers (to recover the HTTP status), so had included a very simple script to do so. It had worked fine in the past, but for some reason barfed in this case. A closer look at what was being returned revealed that for some reason, Apache was prepending the ‘normal’ headers with an extra response header:

HTTP/1.1 100 Continue

HTTP/1.1 200 OK Date: Fri, 09 Jun 2006 15:23:42 GMT
Server: Apache

A bit of Googling revealed that this was to do with a header that cURL sends by default:

Expect: 100-continue

…which in turns tells Apache to send the extra header. I poked around a fair bit but couldn’t quite find a workable solution short of manually removing the header in PHP, which seemed a bit clumsy. Finally, on a hunch I tried this:

curl_setopt( $curl_handle, CURLOPT_HTTPHEADER, array( 'Expect:' ) );

…which basically overrides the original ‘Expect:’ header with an empty one.

Hope this helps someone.

Get a Trackback link

1 Trackbacks/Pingbacks

  1. Pingback: PHP and cURL: Disabling 100-continue header | Stickblog on May 23, 2009


  1. DeyV on December 3, 2006

    It was very helpful.

    many Thanks.

  2. Murray McDonald on July 8, 2008

    Good hunch! Saved me a lot of time. Thanks.

  3. mike on August 13, 2008

    This did help me. Thank you.

    Lighttpd fails the request with an Expect: 100-continue header. Bleh. nginx had no problems :)

  4. Matthom on December 29, 2008

    This helped me out in a pinch! thanks!

  5. Jono Sheppard on June 25, 2009

    This helped – was trying to send a raw SOAP request but curl couldn’t move past the initial “continue” until I tried this. Thanks!

  6. pawlak on July 6, 2009

    Works very well, tnx :)

  7. Sam on November 13, 2009

    Works perfectly, thanks! :D

  8. Yetkin Sakal on April 4, 2010

    This is a life saver. Thanks!

  9. Watanabex on April 5, 2010

    Thanks for this, it helped a lot!!

  10. Tim Sabat on June 16, 2010

    This solved our issue with Highrise’s API. Thanks for the post.

  11. Vivek Thomas on June 25, 2010

    Thank you so much!!

    I was sitting with this issue for a very very long time :)

  12. Matthew on September 14, 2010

    Thanks a ton, definitely helped me out of a bind

  13. EBITENAHUY on October 10, 2010


  14. Viktorc on December 11, 2010

    Thank you, your simple solution helped me a lot.

  15. Josh on January 14, 2011

    Thanks, you just solved this problem for me to!o!

  16. Nate Abele on January 22, 2011

    That worked wonders. Cheers.

Leave a comment

Comment Policy: First time comments are moderated. Please be patient.