Live data from Hacker News

Uses for cURL

httpkit.com

31–40 of 75 posts

Re: Uses for cURL

#31
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!

Note that -I and -i are different:

-i, --include (HTTP) Include the HTTP-header in the output. The HTTP-header includes things like server-name, date of the document, HTTP-version and more...

-I, --head (HTTP/FTP/FILE) Fetch the HTTP-header only! HTTP-servers feature the command HEAD which this uses to get nothing but the header of a document. When used on an FTP or FILE file, curl displays the file size and last modification time only.

Re: Uses for cURL

#32
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.

Why not just use -i?

Re: Uses for cURL

#33
post #22

I hope tomorrow I'll see an even more useful article on sending email from the command line! Wow. /sarcasm

I'd be interested to know exactly what you mean (I usually don't really get sarcasm). It seems that you think this advice is useless, or that people never use the command line, or something, but I don't really know what. Could you be more specific? I find it useful to understand different points of view. Thanks

Site is "Hacker News", not "How-tos for dummies", last time I checked. Do we really need this kind of stuff in home page? Hardly so. What about an article on how to create a three columns layout with CSS? Or how to edit a file using a text editor? Come on... how to use curl? Really?

Re: Uses for cURL

#34

This title is a bit misleading. I was assuming that I'd be reading about how to use something that wasn't curl?

It got changed, sorry. Original title was "9 uses for cURL everyone should know". Perhaps a bit assumptive.

In my opinion that's a much better title. Thanks for at least submitting it with an informative title.

Re: Uses for cURL

#35

This title is a bit misleading. I was assuming that I'd be reading about how to use something that wasn't curl?

It got changed, sorry. Original title was "9 uses for cURL everyone should know". Perhaps a bit assumptive.

Check out the guidelines here: http://ycombinator.com/newsguidelines.html

They suggest you drop the number and go with something like "Uses for cURL everyone should know" instead.

Re: Uses for cURL

#36

I knew 8 of the 9, but the one I didn't (testing virtual hosts) was worth the cost of reading the entire article. Thanks.

That will only work with named vhosts. Outside of shared hosting / personal web servers, almost everyone uses IP-defined vhosts.

Re: Uses for cURL

#37

Earlier quoted context omitted.

It got changed, sorry. Original title was "9 uses for cURL everyone should know". Perhaps a bit assumptive.

Check out the guidelines here: http://ycombinator.com/newsguidelines.html They suggest you drop the number and go with something like "Uses for cURL everyone should know" instead.

Yep, you're right. Duly noted, thanks.
Post reply on HN