Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Using <code>$headers_new[] = 'Expect:';</code> does work <em>unless</em> the <code>$headers_new</code> array contains a string that is <code>'Expect: 100-continue'</code>. In this case you need to remove it from the array otherwise it will be expecting the 100 continue (logically).</p> <p>Because in your code you use <a href="http://php.net/getallheaders" rel="noreferrer"><code>getallheaders()</code></a> and you're not checking if it contains an <code>Expect: 100-continue</code> header already so this probably is the case in your case.</p> <p>Here is a summary for the general situation (and the script that created it):</p> <pre><code>PHP Curl HTTP/1.1 100 Continue and CURLOPT_HTTPHEADER GET request ..........................................: Continue: No GET request with empty header ........................: Continue: No POST request with empty header .......................: Continue: Yes POST request with expect continue explicitly set .....: Continue: Yes POST request with expect (set to nothing) as well ....: Continue: Yes POST request with expect continue from earlier removed: Continue: No </code></pre> <p>Code:</p> <pre><code>&lt;?php $ch = curl_init('http://www.iana.org/domains/example/'); function curl_exec_continue($ch) { curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); $continue = 0 === strpos($result, "HTTP/1.1 100 Continue\x0d\x0a\x0d\x0a"); echo "Continue: ", $continue ? 'Yes' : 'No', "\n"; return $result; } echo "GET request ..........................................: ", !curl_exec_continue($ch); $header = array(); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); echo "GET request with empty header ........................: ", !curl_exec_continue($ch); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, array('hello')); echo "POST request with empty header .......................: ", !curl_exec_continue($ch); $header[] = 'Expect: 100-continue'; curl_setopt($ch, CURLOPT_HTTPHEADER, $header); echo "POST request with expect continue explicitly set .....: ", !curl_exec_continue($ch); $header[] = 'Expect:'; curl_setopt($ch, CURLOPT_HTTPHEADER, $header); echo "POST request with expect (set to nothing) as well ....: ", !curl_exec_continue($ch); unset($header[0]); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); echo "POST request with expect continue from earlier removed: ", !curl_exec_continue($ch); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload