Welcome Guest, Not a member yet? Register   Sign In
curl error 'client gone'
#1

Hi all,
I realize this might not be the best place to ask but I'm out of ideas so I hope someone here could help me out.
I have the following curl request:
PHP Code:
        $arrOptions = [
            
'base_uri' => $this->_apiURI()
            , 
'http_errors' => false
            
'verify' => false
            
'debug' => true
        
];
        
$this->_Request = \Config\Services::curlrequest(
                
$arrOptions
                
null
                
null
                
false
                
);
        
$this->_Response $this->_Request->get'productInfo' ); 

where $this->_apiURI is the root of the API interface I'm trying to access.
When I do this from my Mac using MAMP 5, everything works fine.

Once I move it to a Windows server with IIS, this call fails with the error code 400, subcode 604 - which means client gone.
Now if I put a simple curl request file in the root of my web on the windows server, the code works fine as well:
PHP Code:
$ch curl_init();

curl_setopt($chCURLOPT_URL$apiURI "/productInfo");
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
curl_setopt($chCURLOPT_SSL_VERIFYPEER0);

$result curl_exec($ch);
$info curl_getinfo($ch) ;
curl_close($ch); 

So the most obvious conclusion (and I realize it can be the wrong one) is that the CURLRequest class does something to the request on windows that causes this behavior.
Any insights are very appreciated, thanks.
Reply
#2

I have booked some progress: it turns out something along the way attaches the header Content-Length with value 96 to the request and that causes the issue.
Quite weird, especially since the method is GET.
Any thoughts?
Reply
#3

Finally, I was able to determine where it's coming from. It's the CodeIgniter\HTTP\Message::populateHeaders method
It takes all the elements of the $_SERVER array who's key starts with HTTP_ and makes headers from them.
I am not sure what the logic behind is but in the case of sending a GET curl request it surely does more damage than good.
Is this by design and I need to configure my curl request to circumvent the faulty result or is this a buggy behavior?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB