Hello,
Thanks Jason for sharing a link to HTTPIE.
HTTPIE is basically a command line util to make interaction with your webservices. You can use it so effectively that you will wonder why you were using old styled scripts to perform tasks that can be done easily with this tool.
This post is about setting up httpie. httpie can be used for debugging, automating tests, and for general interaction with your web services.
Ok so lets get started.
Step 1
HTTPIE is python based so you will need python on your windows box. You can get a 32 bit or 64 bit installer from here
http://www.python.org/download/
Run the installer and I think by default it will try to install it to this path
c:\Python32
Now that you’ve got Python Installed, Open Advanced system settings under
Control Panel\All Control Panel Items\System
And add c:\Python32 and C:\Python32\Scripts to the Path variable as shown below. Scripts folder is where our HTTP command lives that I will show you in a while.

Now that our Python is setup we will install curl library now
Step 2
Goto http://curl.haxx.se/download.html and Under Win32 -Generic, you should find curl package for win 2000/XP version 7.27.0. Direct link to download the library is below
Download the library and extract it to
c:\tools
Add c:\tools to your environment path just so that curl command is available from anywhere.
Step 3
Fire up your command prompt as administrator now that both curl.exe and python.exe available, execute this command to install setuptools
c:\tools\curl.exe http://python-distribute.org/distribute-setup.py | python
Step 4
Install Python package installer util called pip
More details can be found here https://github.com/pypa/pip
to install pip run this command
c:\tools\curl.exe -k https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
If everything went on smoothly you will get this message
Successfully installed pip Cleaning up...
Step 5
Now lets install httpie as all the requirements has been met, run this command from your command prompt
pip install -U https://github.com/jkbr/httpie/tarball/master
pip.exe lives under Scripts folder under c:\Python32 that where you installed your python to.
After the installation has been finished you will have http.exe available under c:\Python32\Scripts folder.
Step 6
Fire up command prompt as Administrator and start playing with httpie
There are heaps of useful examples here
https://github.com/jkbr/httpie#readme
But lets cover a couple of things.
Basic Request
Run this command
http http://jaspreetchahal.org/examples/webservice.php
And you will get this back from my demos site
Hello HTTPIE
Form submissions (POST)
Run this command
http --form POST http://jaspreetchahal.org/examples/webservice.php first_name=Jaspreet last_name=chahal ispost==true
will print
first_name: Jaspreet last_name: chahal
Print JSON
Run this command
http http://jaspreetchahal.org/examples/webservice.php first_name=Jaspreet last_name=chahal printjson==true
will print this
{"first_name": "Jaspreet", "last_name": "chahal"}
PHP code on the server that I used is below, its just a basic code to highlight how httpie can be utilized so don’t try to analyze the code as it is just for demo sake.
echo "first_name: ".$_POST["first_name"]." \nlast_name:".$_POST["last_name"]; else echo "Hello HTTPIE";
Just read the documentation of this lovely tool and I am sure that you will not regret using it as it is such an awesome util.
I hope this post kick starts your willing to play with httpie from your windows box
Cheers
Advertisement





JC WordPress Coupon Revealer Plugin Pro License
Australian Street Names with City, State and Display Names only, Single Server License
Recent Comments