By default curl sends Accept: */*
header for all requests. How do I stop sending of the default header?
Accept: */*
Curl by default adds headers such as Content-type and User-agent .
php file with the following contents. $url = 'https://www.example.com' ; $curl = curl_init(); curl_setopt( $curl , CURLOPT_URL, $url );
PHP cURL is a library that is the most powerful extension of PHP. It allows the user to create the HTTP requests in PHP. cURL library is used to communicate with other servers with the help of a wide range of protocols. cURL allows the user to send and receive the data through the URL syntax.
cURL is a PHP extension that allows you to use the URL syntax to receive and submit data. cURL makes it simple to connect between various websites and domains.
Pass in "Accept:" (ie a header with no contents to the right of the colon) with CURLOPT_HTTPHEADER. Like:
$headers = array( "Accept:" ); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
The equivalent using the curl command line tool is:
curl -H 'Accept:' http://example.com/
This will make curl remove the header, not just send a header with a blank value. You can also send a header with a blank value if you want, but then you need to use a semicolon instead of colon!
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