I want to set header origin when connecting to some url that not owned by me
is it possible to set server [HTTP_ORIGIN] via CURL
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Origin: somevalue'));
CURLOPT_RETURNTRANSFER. true to return the transfer as a string of the return value of curl_exec() instead of outputting it directly. CURLOPT_SASL_IR. true to enable sending the initial response in the first packet. Added in cURL 7.31.
The curl_setopt() function will set options for a CURL session identified by the ch parameter. The option parameter is the option you want to set, and the value is the value of the option given by the option. The value should be a long for the following options (specified in the option parameter):
AFAIK, it will wait for a response before continuing running the script. Try adding if ($ret===false) echo curl_error($curl); after the $ret = curl_exec... line - it could be that the command is timing out waiting for a response.
Yes, that will work.
Keep in mind - if setting custom HTTP headers, you must set them all at the same time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With