header.md (2910B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Long: header 5 Short: H 6 Arg: <header/@file> 7 Help: Pass custom header(s) to server 8 Protocols: HTTP IMAP SMTP 9 Category: http imap smtp 10 Added: 5.0 11 Multi: append 12 See-also: 13 - user-agent 14 - referer 15 Example: 16 - -H "X-First-Name: Joe" $URL 17 - -H "User-Agent: yes-please/2000" $URL 18 - -H "Host:" $URL 19 - -H @headers.txt $URL 20 --- 21 22 # `--header` 23 24 Extra header to include in information sent. When used within an HTTP request, 25 it is added to the regular request headers. 26 27 For an IMAP or SMTP MIME uploaded mail built with --form options, it is 28 prepended to the resulting MIME document, effectively including it at the mail 29 global level. It does not affect raw uploaded mails (Added in 7.56.0). 30 31 You may specify any number of extra headers. Note that if you should add a 32 custom header that has the same name as one of the internal ones curl would 33 use, your externally set header is used instead of the internal one. This 34 allows you to make even trickier stuff than curl would normally do. You should 35 not replace internally set headers without knowing perfectly well what you are 36 doing. Remove an internal header by giving a replacement without content on 37 the right side of the colon, as in: -H `Host:`. If you send the custom header 38 with no-value then its header must be terminated with a semicolon, such as -H 39 `X-Custom-Header;` to send `X-Custom-Header:`. 40 41 curl makes sure that each header you add/replace is sent with the proper 42 end-of-line marker, you should thus **not** add that as a part of the header 43 content: do not add newlines or carriage returns, they only mess things up for 44 you. curl passes on the verbatim string you give it without any filter or 45 other safe guards. That includes white space and control characters. 46 47 This option can take an argument in @filename style, which then adds a header 48 for each line in the input file. Using @- makes curl read the header file from 49 stdin. (Added in 7.55.0) 50 51 Please note that most anti-spam utilities check the presence and value of 52 several MIME mail headers: these are `From:`, `To:`, `Date:` and `Subject:` 53 among others and should be added with this option. 54 55 You need --proxy-header to send custom headers intended for an HTTP proxy. 56 (Added in 7.37.0) 57 58 Passing on a `Transfer-Encoding: chunked` header when doing an HTTP request 59 with a request body, makes curl send the data using chunked encoding. 60 61 **WARNING**: headers set with this option are set in all HTTP requests - even 62 after redirects are followed, like when told with --location. This can lead to 63 the header being sent to other hosts than the original host, so sensitive 64 headers should be used with caution combined with following redirects. 65 66 `Authorization:` and `Cookie:` headers are explicitly *not* passed on in HTTP 67 requests when following redirects to other origins, unless --location-trusted 68 is used.