HTTP Headers
Every HTTP request and response is sent with a number of headers that facilitate communication between the client and server or provide meta-information about itself. Some headers will be automatically generated for you as part of the client making the request, such as Host
, User-Agent
, or Content-Length
. It is important to be familiar with the extra headers you might want to include when making a request, as they can give you some control over the response you receive or the headers that might even be required for the request to be accepted.
The first of these is the Accept
header. It allows you to specify a comma-separated list of content types expressed as a MIME type, such as text/html
or application/json
, which will be used to negotiate with the server to determine a mutual response body so that the client can correctly parse the request. The client may provide multiple content types it will accept, and the server will select one and specify which content type...