Make POST request with large file in body for PHP 5.5+
<p>There is an API I need to work with from my PHP application. One endpoint receives a file to upload as a body of the POST request. The uploaded file can be rather huge (up to 25GB). The endpoint returns a simple JSON content with either <code>200 OK</code> or different other status codes.</p>

<p>Example request may look like this:</p>

<pre><code>POST /api/upload HTTP/1.1
Host: &lt;hostname&gt;
Content-Type: application/octet-stream
Content-Length: 26843545600
Connection: close

&lt;raw file data up to 25 GB&gt;
</code></pre>

<p>Basically, I need to write a method that will perform such request without killing the server.</p>

<p>I tried to find any reasonable implementation but, from what I can see, both cURL and non-cURL (<code>stream_context_create</code>) methods require <em>string</em> request body, which may exhaust server memory.</p>

<p>Is there any simple way to achieve this without writing <a href="http://php.net/manual/en/function.fsockopen.php" rel="nofollow">a separate socket transport layer</a>?</p>