Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Apr 182011
 

Show HTTP response header using curl

Answer:

To show the response of HTTP request to a specific server, you can use the "curl -i" command.

Example:

#  curl -i "http://www.example.com"
HTTP/1.0 302 Found
Location: http://www.iana.org/domains/example/
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

Update: Thanks Robin Clowers for the update.

  2 Responses to “Show HTTP response header using curl”

  1. This is wrong, -I makes a HEAD request:
    -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 a FTP or FILE file, curl displays the file size and last modification time only.

    You want -i, which includes headers.

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

  2. @Robin Clowers, thanks, I have updated the article.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>