PHP Curl http code 100 and failing
curl, http-status-code-100, php, rest, web-services
Solution
You're sending a wrong `Content-Length` value. That's why the server expects a request body. Because you aren't sending any data, `Content-Length` should be set to `0`.
$header = array('Content-Length: 0', 'Content-Type: application/json', 'Authorization: '. $authorization, 'Authorization-Admin: '. $authorization_admin);
When you decide to compose request header manually, make sure `Content-Length` is set to a correct value.
Problem
I'm trying to use a web service with php curl but I'm getting the http code "100" and an "Recv failure: Connection was reset" error.. I tested the web service with google chrome's extension "Postman -REST Client" and it works perfectly. I searched this http code and it looks like the server is expecting a body request data but I don't know what it's expecting me to send since I'm not posting any data, just the headers. My code looks like this: ``` error_reporting(-1); $header = array('Content-Length: 1831', 'Content-Type: application/json', 'Authorization: '. $authorization, 'Authorization-Admin: '. $authorization_admin); $url = 'http://api.bookingreports.com/public/1/analytics/reports/departures'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); $result = curl_exec($ch); $errorCode = curl_getinfo($ch, CURLINFO_HEADER_OUT); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); echo $result; echo curl_error($ch); echo $errorCode; echo $httpcode; //log_message('debug', 'HTTP HEADER '. $errorCode); curl_close($ch); ``` and the header I'm sending looks like this: ``` POST /public/1/analytics/reports/departures HTTP/1.1 Host: api.bookingreports.com Accept: */* Content-Length: 1831 Content-Type: application/json Authorization: myauthcode Authorization-Admin: myauthadmin Expect: 100-continue ```