从 HTTPie 的请求中删除默认 HTTP Headers
Remove default HTTP Headers from HTTPie's request
有几个 default headers that HTTPie sets。我想知道是否有办法删除一些 header,例如 Accept-Encoding
?
我喜欢取消设置的原因 Accept-Encoding
是为了检查我们的服务器关于 HTTP 压缩的行为。
根据 https://github.com/jakubroztocil/httpie#http-headers , you can override those headers. For example, set Accept-Encoding
to empty to achieve the same effect as if you had removed it -- per the rules at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 .
添加 Headers 后跟一个冒号。
- 没有headers:
http -v https://jsonplaceholder.typicode.com/todos/1 \
Accept: \
Accept-Encoding: \
Connection: \
Host: \
User-Agent:
要求:
GET /todos/1 HTTP/1.1
Host: jsonplaceholder.typicode.com
回复:
HTTP/1.1 200 OK
...
- 标准:
http -v https://jsonplaceholder.typicode.com/todos/1
要求:
GET /todos/1 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: jsonplaceholder.typicode.com
User-Agent: HTTPie/0.9.8
回复:
HTTP/1.1 200 OK
...
-v
选项显示请求。另外,请记住在多行 bash 命令中 \
后没有空格。
有几个 default headers that HTTPie sets。我想知道是否有办法删除一些 header,例如 Accept-Encoding
?
我喜欢取消设置的原因 Accept-Encoding
是为了检查我们的服务器关于 HTTP 压缩的行为。
根据 https://github.com/jakubroztocil/httpie#http-headers , you can override those headers. For example, set Accept-Encoding
to empty to achieve the same effect as if you had removed it -- per the rules at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 .
添加 Headers 后跟一个冒号。
- 没有headers:
http -v https://jsonplaceholder.typicode.com/todos/1 \
Accept: \
Accept-Encoding: \
Connection: \
Host: \
User-Agent:
要求:
GET /todos/1 HTTP/1.1
Host: jsonplaceholder.typicode.com
回复:
HTTP/1.1 200 OK
...
- 标准:
http -v https://jsonplaceholder.typicode.com/todos/1
要求:
GET /todos/1 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Host: jsonplaceholder.typicode.com
User-Agent: HTTPie/0.9.8
回复:
HTTP/1.1 200 OK
...
-v
选项显示请求。另外,请记住在多行 bash 命令中 \
后没有空格。