HTTP Request using cURL for Windows

There’s a variety of ways to perform http request without using your web browser, i.e. using your command prompt. We could use wget for most major Linux distributions, but what about Windows? Recently I’ve found out that cURL might get the job done.

cURL is a command line tool for transferring files with URL syntax. It is free and open source software. One of the use for cURL is to automate unattended file transfers. For example, automating file downloads or getting html output from sites, via a command prompt, a batch file or scheduled job. It is also a good tool for simulating a user’s actions at a web browser, thus a very good tool to perform web application tests.

How to use cURL:

1. Download cURL. Select appropriate version based on your OS.
2. Extract the zip file.
3. Place the “curl.exe” under your C:\WINDOWS directory.
4. Execute it directly from your command prompt:

C:\>curl http://www.wordpress.org

You will see a bunch of http response coming out of your command prompt.

Output http response and save the page locally :
C:\>curl http://www.mydomain.com/mypage.php > mypage.html

Downloading using cURL:
C:\>curl http://www.mydomain.com/downloads/myfile.zip

HTTP Post using cURL:
C:\>curl -d "string_to_post" http://www.mydomain.com/mypage.aspx

There’s a lot more features for cURL, and the manual usage available here.

Related Posts:

  • No Related Posts

8 Comments

Rizal

Thanks, this is very useful knowledge. I have used cURL before but in PHP. I never realized it was available as a Windows command-line tool.

Ady

@Rizal: PHP’s curl binding uses libcurl which originates from the same project. As a matter of fact this is one big plus feature against wget — API.

I use curl even in Linux, especially when troubleshooting pages. As for wget, I use it to download simple files. For big files, I use lftp which has the ability to leech using multiple connections. MUAHAHAHA (evil laugh).

Leave a Reply

Your email address will not be published. Required fields are marked *