仅限Curl发布数据和标头 [英] Curl post data and headers only

查看:304
本文介绍了仅限Curl发布数据和标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从卷曲请求中获取标头

I want to get the headers only from a curl request

curl -I www.google.com

全部。现在我想这样做,但传递post数据:

All grand. Now I want to do that but to pass in post data too:

curl -I -d'test = test'www.google.com

但是我得到的是:

警告:你只能选择一个HTTP请求!

任何人都知道如何做到这一点,或者我做一些愚蠢的事情?

Anyone have any idea how to do this or am I doing something stupid?

推荐答案

-I 选项告诉curl执行HEAD请求, $ c> -d'test = test'选项告诉curl做一个POST,所以你告诉curl做两种不同的请求类型。

The -I option tells curl to do a HEAD request while the -d'test=test' option tells curl to do a POST, so you're telling curl to do two different request types.

curl -s -d'test=test' -D- -o/dev/null www.google.com 

或在Windows上:

or, on Windows:

curl -s -d'test=test' -D- -onul: www.google.com 

这是最简单的方法做到这一点,只要我能找到。选项是:

That is the neatest way to do this as far as I can find. The options are:


  • -D - 将标题转储到列出的文件, $ $ c>将正文发送到列出的文件。

  • -s 静音(无进度条)

  • -D- Dump the header to the file listed, or stdout when - is passed, like this.
  • -o/dev/null Send the body to the file listed. Here, we discard the body so we only see the headers.
  • -s Silent (no progress bar)

这篇关于仅限Curl发布数据和标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆