Hacker Newsnew | comments | show | ask | jobs | submitlogin

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.

-----


Why not just use -i?

-----


-i mixes the header and the body of the response into one stream. If you want only the header it won't help.

-----


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.

-----




Applications are open for YC Summer 2015

Guidelines | FAQ | Support | API | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: