Add Header Function

The add_header function adds a new header. You can use it only for a request. You cannot use it for a reply. It uses the following format:

add_header(name, value)

where:

  • name is a string that contains the header name.

  • value is a string that contains the header value.

For example, the following code adds the content type for the request:

req.get_headers().add_header("Content-Type", "text/html");

For more information, see Request Object and Response Object.