-H, –header <header>
原生申请头
curl -v -X POST localhost:8081/health
自定义申请头
curl -v -X POST localhost:8081/health –header “X-Custom-Header;” –header “token:sneaky” –header “Host: baidu:8081” –header “User-Agent:”
通过图片可察看到:
- 可重写 curl 命令自带的申请头。curl 命令外部自带的申请头 Host: localhost:8081 被批改成了Host: baidu:8081。
- 可移除 curl 命令自带的申请头。curl 命令外部自带的申请头 User-Agent: curl/8.0.1,被通过自定义申请头–header “User-Agent:” 移除了。
- 可自定义申请值为空的申请头。自定义申请头 X-Custom-Header: 是空值,通过设置申请头为:–header “X-Custom-Header;”。
-
能够同时增加多个自定义申请头。
服务器后盾输入
- (HTTP) Extra header to use when getting a web page.
- You may specify any number of extra headers.
- Note that if you should add a custom header that has the same name as one of the internal ones curl would use, your externally set header will be used instead of the internal one. This allows you to make even trickier stuff than curl would normally do.
- You should not replace internally set headers without knowing perfectly well what you’re doing.
- Remove an internal header by giving a replacement without content on the right side of the colon, as in: -H “Host:”.
- If you send the custom header with no-value then its header must be terminated with a semicolon, such as -H “X-Custom-Header;” to send “X-Custom-Header:”.
- curl will make sure that each header you add/replace is sent with the proper end-of-line marker, you should thus not add that as a part of the header content: do not add newlines or carriage returns, they will only mess things up for you.
- See also the -A, –user-agent and -e, –referer options.
- This option can be used multiple times to add/replace/remove multiple headers.