xref: /aosp_15_r20/external/curl/docs/cmdline-opts/header.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: header
5*6236dae4SAndroid Build Coastguard WorkerShort: H
6*6236dae4SAndroid Build Coastguard WorkerArg: <header/@file>
7*6236dae4SAndroid Build Coastguard WorkerHelp: Pass custom header(s) to server
8*6236dae4SAndroid Build Coastguard WorkerProtocols: HTTP IMAP SMTP
9*6236dae4SAndroid Build Coastguard WorkerCategory: http imap smtp
10*6236dae4SAndroid Build Coastguard WorkerAdded: 5.0
11*6236dae4SAndroid Build Coastguard WorkerMulti: append
12*6236dae4SAndroid Build Coastguard WorkerSee-also:
13*6236dae4SAndroid Build Coastguard Worker  - user-agent
14*6236dae4SAndroid Build Coastguard Worker  - referer
15*6236dae4SAndroid Build Coastguard WorkerExample:
16*6236dae4SAndroid Build Coastguard Worker  - -H "X-First-Name: Joe" $URL
17*6236dae4SAndroid Build Coastguard Worker  - -H "User-Agent: yes-please/2000" $URL
18*6236dae4SAndroid Build Coastguard Worker  - -H "Host:" $URL
19*6236dae4SAndroid Build Coastguard Worker  - -H @headers.txt $URL
20*6236dae4SAndroid Build Coastguard Worker---
21*6236dae4SAndroid Build Coastguard Worker
22*6236dae4SAndroid Build Coastguard Worker# `--header`
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard WorkerExtra header to include in information sent. When used within an HTTP request,
25*6236dae4SAndroid Build Coastguard Workerit is added to the regular request headers.
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard WorkerFor an IMAP or SMTP MIME uploaded mail built with --form options, it is
28*6236dae4SAndroid Build Coastguard Workerprepended to the resulting MIME document, effectively including it at the mail
29*6236dae4SAndroid Build Coastguard Workerglobal level. It does not affect raw uploaded mails (Added in 7.56.0).
30*6236dae4SAndroid Build Coastguard Worker
31*6236dae4SAndroid Build Coastguard WorkerYou may specify any number of extra headers. Note that if you should add a
32*6236dae4SAndroid Build Coastguard Workercustom header that has the same name as one of the internal ones curl would
33*6236dae4SAndroid Build Coastguard Workeruse, your externally set header is used instead of the internal one. This
34*6236dae4SAndroid Build Coastguard Workerallows you to make even trickier stuff than curl would normally do. You should
35*6236dae4SAndroid Build Coastguard Workernot replace internally set headers without knowing perfectly well what you are
36*6236dae4SAndroid Build Coastguard Workerdoing. Remove an internal header by giving a replacement without content on
37*6236dae4SAndroid Build Coastguard Workerthe right side of the colon, as in: -H `Host:`. If you send the custom header
38*6236dae4SAndroid Build Coastguard Workerwith no-value then its header must be terminated with a semicolon, such as -H
39*6236dae4SAndroid Build Coastguard Worker`X-Custom-Header;` to send `X-Custom-Header:`.
40*6236dae4SAndroid Build Coastguard Worker
41*6236dae4SAndroid Build Coastguard Workercurl makes sure that each header you add/replace is sent with the proper
42*6236dae4SAndroid Build Coastguard Workerend-of-line marker, you should thus **not** add that as a part of the header
43*6236dae4SAndroid Build Coastguard Workercontent: do not add newlines or carriage returns, they only mess things up for
44*6236dae4SAndroid Build Coastguard Workeryou. curl passes on the verbatim string you give it without any filter or
45*6236dae4SAndroid Build Coastguard Workerother safe guards. That includes white space and control characters.
46*6236dae4SAndroid Build Coastguard Worker
47*6236dae4SAndroid Build Coastguard WorkerThis option can take an argument in @filename style, which then adds a header
48*6236dae4SAndroid Build Coastguard Workerfor each line in the input file. Using @- makes curl read the header file from
49*6236dae4SAndroid Build Coastguard Workerstdin. (Added in 7.55.0)
50*6236dae4SAndroid Build Coastguard Worker
51*6236dae4SAndroid Build Coastguard WorkerPlease note that most anti-spam utilities check the presence and value of
52*6236dae4SAndroid Build Coastguard Workerseveral MIME mail headers: these are `From:`, `To:`, `Date:` and `Subject:`
53*6236dae4SAndroid Build Coastguard Workeramong others and should be added with this option.
54*6236dae4SAndroid Build Coastguard Worker
55*6236dae4SAndroid Build Coastguard WorkerYou need --proxy-header to send custom headers intended for an HTTP proxy.
56*6236dae4SAndroid Build Coastguard Worker(Added in 7.37.0)
57*6236dae4SAndroid Build Coastguard Worker
58*6236dae4SAndroid Build Coastguard WorkerPassing on a "Transfer-Encoding: chunked" header when doing an HTTP request
59*6236dae4SAndroid Build Coastguard Workerwith a request body, makes curl send the data using chunked encoding.
60*6236dae4SAndroid Build Coastguard Worker
61*6236dae4SAndroid Build Coastguard Worker**WARNING**: headers set with this option are set in all HTTP requests - even
62*6236dae4SAndroid Build Coastguard Workerafter redirects are followed, like when told with --location. This can lead to
63*6236dae4SAndroid Build Coastguard Workerthe header being sent to other hosts than the original host, so sensitive
64*6236dae4SAndroid Build Coastguard Workerheaders should be used with caution combined with following redirects.
65