在命令行上进行 HTTP 测试,还有比 cURL 更好的吗?

发布于 2024-11-07 21:20:31 字数 232 浏览 0 评论 0原文

是否有一个命令行实用程序,您可以在其中简单地设置 HTTP 请求并将跟踪简单地输出回控制台?

另外,简单地指定方法将是一个很好的功能,而不是方法的副作用。

我可以使用 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

天邊彩虹 2024-11-14 21:20:31

我不喜欢回答我自己的问题,但 c-smile 的回答让我走上了正确的道路:

Short Answer shell script over cURL:

curl --dump-header - "$@"

The - [dash]meaning stdout is a convention I was notwareed but also work for wget and a number of other unix公用事业。它显然不是 shell 的一部分,而是内置于每个实用程序中。 wget 等效项是:

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

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 - "$@"
狼性发作 2024-11-14 21:20:31

您是否尝试过 wget:
http://www.gnu.org/software/wget/manual /wget.html#Wgetrc-命令
就像wget --save-headers ...

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

£烟消云散 2024-11-14 21:20:31

要在输出(以及服务器响应)中包含 HTTP 标头,只需使用 curl-i/--include 选项。例如:

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

man curl 对此设置的描述如下:

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

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.
巷雨优美回忆 2024-11-14 21:20:31

尝试 http,例如

http -v example.org

进一步访问 https://httpie.org

它甚至包括一个在线尝试的页面:

https://httpie.org/run

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

蘑菇王子 2024-11-14 21:20:31

Telnet 长期以来一直是一种众所周知的(虽然我猜现在已经被遗忘了)查看网页的工具。总体思路是远程登录到 http 端口,键入 http 1.1 GET 命令,然后在屏幕上查看所提供的页面。

一个很好的详细解释是 http://support.microsoft.com/kb/279466

一个<一href="http://www.google.com/search?hl=&q=netgear+fvs318g+user+manual&sourceid=navclient-ff&rlz= 1B3GGHP_enUS431&ie=UTF-8#hl=en&sugexp=ldymls&pq=telnet%20to%20web%20page%20get&xhr=t&q=t elnet+web+page+get&cp=7&pf=p&sclient=psy&rlz=1B3GGHP_enUS431&source=hp&aq=0j&aqi =&aql=&oq=telnet+web+page+get&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=c47720ba43ce4197&bs=1" rel="nofollow"> Google 搜索 会产生更多结果。

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.

硪扪都還晓 2024-11-14 21:20:31

在端口 80 上使用 telnet

例如:

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

表示 Enter

Use telnet on port 80

For example:

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

<CR> means Enter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文