How to set the authorization header using cURL

http://curl.se/docs/httpscripting.html See part 6. HTTP Authentication HTTP Authentication HTTP Authentication is the ability to tell the server your username and password so that it can verify that you’re allowed to do the request you’re doing. The Basic authentication used in HTTP (which is the type curl uses by default) is plain text based, which means … Read more

Set cURL to use local virtual hosts

Actually, curl has an option explicitly for this: –resolve Instead of curl -H ‘Host: yada.com’ http://127.0.0.1/something use curl –resolve ‘yada.com:80:127.0.0.1′ http://yada.com/something What’s the difference, you ask? Among others, this works with HTTPS. Assuming your local server has a certificate for yada.com, the first example above will fail because the yada.com certificate doesn’t match the 127.0.0.1 … Read more

CURLOPT_FOLLOWLOCATION cannot be activated [duplicate]

Set safe_mode = Off in your php.ini file (it’s usually in /etc/ on the server). If that’s already off, then look around for the open_basedir stuff in the php.ini file, and change it accordingly. Basically, the follow location option has been disabled as a security measure, but PHP’s built-in security features are usually more annoying … Read more

How to display request headers with command line curl

curl’s -v or –verbose option shows the HTTP request headers, among other things. Here is some sample output: $ curl -v http://google.com/ * About to connect() to google.com port 80 (#0) * Trying 66.102.7.104… connected * Connected to google.com (66.102.7.104) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.16.4 (i386-apple-darwin9.0) libcurl/7.16.4 OpenSSL/0.9.7l zlib/1.2.3 > … Read more