Live data from Hacker News

Uses for cURL

httpkit.com

11–20 of 75 posts

Re: Uses for cURL

#12
post #10

I would strongly suggest HTTPie for the majority of these tasks: https://github.com/jkbr/httpie

May I ask why? What benefits does HTTPie have?

I prefer HTTPie because after years of using curl, I still have to Google simple use cases. HTTPie has a very simple a intuitive api.

Re: Uses for cURL

#13
post #10

I would strongly suggest HTTPie for the majority of these tasks: https://github.com/jkbr/httpie

May I ask why? What benefits does HTTPie have?

The GitHub page does a good job of highlighting all of the benefits HTTPie has if you're already familiar with cURL. But for me it's the design of the interface with syntax highlighting being the sugar on top.

See: https://github.com/jkbr/httpie#interface-design , https://github.com/jkbr/httpie#redirected-input , https://github.com/jkbr/httpie#usage

Re: Uses for cURL

#14
post #5

> If you only care about headers use the -I flag and the response body will be hidden That is actually wrong. The -I flag set the request method to HEAD. So in some cases it will return different headers than a normal get request (and some servers don't implement HEAD responses at all).

Ah, great catch. Added a note about having to specify the method explicitly / that -I uses HEAD implicitly. Thanks!

A better way to view only the header of a response is using the flags -o to redirect the body and -D to redirect the header of the response. When I want to print only the header to stdout I do

    curl -o/dev/null -D- http://www.example.com
-I does not work with methods other than GET. This does the job.

Re: Uses for cURL

#15
I generally use wget myself. For basic HTTP debugging needs, I run ":%!wget -Sd http://www.example.com inside a new vim buffer. Then I can read the Varnish headers or whatever and figure out what's going on.

I ran into an issue where the SSL implementation was a bit dated, though, and didn't recognize how a GoDaddy cert implemented multiple hostnames -- but it turned out to follow the standard. wget was just lacking in its implementation and reporting an error when the cert was fine.

Re: Uses for cURL

#16
Helpful. I 'know' these, but this is a good cheat sheet to save around.

Really like the casual plug of your new project; I signed up :-)

Re: Uses for cURL

#17
If you're on windows and don't feel like using the commandline you can click around in Fiddler to achieve similar things. The help is much shorter http://www.fiddler2.com/fiddler/help/composer.asp

I wasn't able to change the Host header successfully, though. A workaround is needed: https://groups.google.com/forum/?fromgroups=#!topic/httpfidd...

Re: Uses for cURL

#18
post #14

Earlier quoted context omitted.

Ah, great catch. Added a note about having to specify the method explicitly / that -I uses HEAD implicitly. Thanks!

A better way to view only the header of a response is using the flags -o to redirect the body and -D to redirect the header of the response. When I want to print only the header to stdout I do curl -o/dev/null -D- http://www.example.com -I does not work with methods other than GET. This does the job.

So you can use -I with another method, but as soon as you add a body curl refuses. Went ahead and just took that scenario out of the post -- but your redirection snippet is great.

Re: Uses for cURL

#19

I would strongly suggest HTTPie for the majority of these tasks: https://github.com/jkbr/httpie

Thanks for this recommendation. I still value tips on using cURL because it is practically ubiquitous which is helpful when you are logged into some random server, but HTTPie definitely has a very common sense usage and I think it will be very useful as a testing tool for my local machine.

Re: Uses for cURL

#20

I would strongly suggest HTTPie for the majority of these tasks: https://github.com/jkbr/httpie

And I will continue to pitch our curlish instead which does not replace curl but amends it: http://packages.python.org/curlish/

It just wraps curl and adds some nicer options, cookie handling, oauth and colorizing to it. Same command line you are already used to but with some extras that simplify live and make it more enjoyable.

Post reply on HN