Requests icon indicating copy to clipboard operation
Requests copied to clipboard

Requests_Exception with message 'cURL error 18: transfer closed with 1 bytes remaining to read'

Open carcinocron opened this issue 9 years ago • 1 comments

http://stackoverflow.com/questions/1759956/curl-error-18-transfer-closed-with-outstanding-read-data-remaining

The stackoverflow says that I might be able to work around this by forcing HTTP1.0

Assuming this error is the server's fault, I'm not sure how to do this via Requests:

curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

carcinocron avatar Dec 07 '16 18:12 carcinocron

I was able to reproduce this in cURL. It does actually work with CURL_HTTP_VERSION_1_0, but the last character is (predictably) missing.

This is working for now. I'm able to manually add the } manually to read the JSON. The HTTP server should be in Express.js behind an nginx, I'll try to come up with a solution for why that is dropping the last byte.

$response = curl_exec($curl);
$responseData = json_decode($response.'}',true);

carcinocron avatar Dec 07 '16 20:12 carcinocron