William
William

Reputation: 6428

HTTP testing on the command line, is there something better than cURL?

Is there a command line utility where you can simply set up an HTTP request and have the trace simply output back to the console?

Also specifying the method simply would be a great feature instead of the method being a side effect.

I can get all the information I need with cURL but I can't figure out a way to just display it without dumping everything to files.

I'd like the output to show the sent headers the received headers and the body of the message.

There must be something out there but I haven't been able to google for it. Figured I should ask before going off and writing it myself.

Upvotes: 4

Views: 34106

Answers (6)

Max MacLeod
Max MacLeod

Reputation: 26652

Try http, e.g.

http -v example.org

Further into at https://httpie.org

It even includes a page to try online:

https://httpie.org/run

Upvotes: 3

user188276
user188276

Reputation:

Use telnet on port 80

For example:

telnet telehack.com 80
GET / HTTP/1.1
host: telehack.com
<CR>
<CR>

<CR> means Enter

Upvotes: 0

Mathias Bynens
Mathias Bynens

Reputation: 149534

To include the HTTP headers in the output (as well as the server response), just use curl’s -i/--include option. For example:

curl -i "http://www.google.com/"

Here’s what man curl says about this setting:

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

      If  this  option  is  used  twice, the second will again disable
      header include.

Upvotes: 2

William
William

Reputation: 6428

I dislike answering my own question but c-smile's answer lead me down the right track:

Short answer shell script over cURL:

curl --dump-header - "$@"

The - [dash] meaning stdout is a convention I was unaware of but also works for wget and a number of other unix utilities. It is apparently not part of the shell but built into each utility. The wget equivalent is:

wget --save-headers -qO - "$@"

Upvotes: 4

Pete Wilson
Pete Wilson

Reputation: 8694

Telnet has for long been a well-known (though now forgotten, I guess) tool for looking at a web page. The general idea is to telnet to the http port, to type an http 1.1 GET command, and then to see the served page on the screen.

A good detailed explanation is http://support.microsoft.com/kb/279466

A Google search yields a whole bunch more.

Upvotes: 0

c-smile
c-smile

Reputation: 27460

Did you try wget: http://www.gnu.org/software/wget/manual/wget.html#Wgetrc-Commands ? Like wget --save-headers ...

Upvotes: 2

Related Questions