easy:SetOpt_HTTPHeader -- set custom HTTP headers
Pass a table containing a list of HTTP headers to pass to the server and/or proxy in your HTTP request. The same list can be used for both host and proxy requests!

If you add a header that is otherwise generated and used by libcurl internally, your added one will be used instead. If you add a header with no content as in 'Accept:' (no data on the right side of the colon), the internally used header will get disabled. With this option you can add new headers, replace internal headers and remove internal headers. To add a header with no content (nothing to the right side of the colon), use the form 'MyHeader;' (note the ending semicolon).

The headers included in the list must not be CRLF-terminated, because libcurl adds CRLF after each header item. Failure to comply with this will result in strange bugs because the server will most likely ignore part of the headers you specified.

The first line in a request (containing the method, usually a GET or POST) is not a header and cannot be replaced using this option. Only the lines following the request-line are headers. Adding this method line in this list of headers will only cause your request to send an invalid header. Use #CURLOPT_CUSTOMREQUEST to change the method.

Pass a Nil to this option to reset back to no custom headers.

The most commonly replaced headers have "shortcuts" in the options #CURLOPT_COOKIE, #CURLOPT_USERAGENT and #CURLOPT_REFERER. We recommend using those.

There's an alternative option that sets or replaces headers only for requests that are sent with CONNECT to a proxy: #CURLOPT_PROXYHEADER. Use #CURLOPT_HEADEROPT to control the behavior.

input value
e:SetOpt_HTTPHeader({"Custom-Header1: Test", "Custom-Header2: Test"})
The code above adds two custom headers to the HTTP request.

Show TOC