Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP fopen receiving Continue 100 and fail
    primarykey
    data
    text
    <p>Having a problem with trying to do an fopen on php. I'm sending across a data set of about 300kb to a Generic Handler (.ashx file). A solution on either the .Net or PHP side would be welcome. The code I'm using to send:</p> <pre><code>function DoPostRequest($url, $data, $optional_headers = null) { $params = array('http' =&gt; array('method' =&gt; 'POST', 'content' =&gt; $data, 'header' =&gt; "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen ( $data ) . "\r\n")); if($optional_headers != null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); try { ini_set ('user_agent', $_SERVER['HTTP_USER_AGENT']); $fp = fopen($url, 'rb', false, $ctx); $response = stream_get_contents($fp); } catch (Exception $e) { echo 'Exception: '.$e-&gt;getMessage(); } return $response; } </code></pre> <p>This contacts a web server running .Net. The problem is that once the request starts, the .Net server sends a HTTP 1.1 / 100 Continue response. Everything works fine at a smaller data set being sent, but I'm assuming that because the file size is large a Continue is automatically put in by the .Net Framework.</p> <p>I've tried setting the C# code with </p> <pre><code>System.Net.ServicePointManager.Expect100Continue = false; </code></pre> <p>and also changed the Web.config file to include:</p> <pre><code>&lt;system.net&gt; &lt;settings&gt; &lt;servicePointManager expect100Continue="false" /&gt; &lt;/settings&gt; &lt;/system.net&gt; </code></pre> <p>None of this has worked, though. Therefore I'd like to do it on the PHP side. I'm using a vanilla PHP installation (no cURL installed), is there any way to get the fopen to ignore or expect the 100 continue?</p> <p>EDIT: Full error code given:</p> <blockquote> <p>Warning: fopen(http://localhost:59396/Testing.ashx) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 100 Continue in C:\xampp\htdocs\Prototype\Testing.php on line 72</p> </blockquote>
    singulars
    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.
 

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