10 HTTP Headers every API developer should be aware of:
Thread ๐งต
Thread ๐งต
Client and server can pass the extra bit of information with the request and response using HTTP headers.
HTTP headers are not case-sensitive.
HTTP headers are not case-sensitive.
The HTTP headers are divided into four categories:
1๏ธโฃ Request headers: Client to Server
2๏ธโฃ Response headers: Server to Client
3๏ธโฃ Representation headers: Information about the body of the resource
4๏ธโฃ Payload headers: Information about the payload data
1๏ธโฃ Request headers: Client to Server
2๏ธโฃ Response headers: Server to Client
3๏ธโฃ Representation headers: Information about the body of the resource
4๏ธโฃ Payload headers: Information about the payload data
๐ Accept
`Accept` header is used when the client wants to inform the server about the data type the client can understand.
For example,
Accept: image/png
`Accept` header is used when the client wants to inform the server about the data type the client can understand.
For example,
Accept: image/png
๐ Accept-Encoding
The `Accept-Encoding` header is usually attached with a request to the server, indicating which encoding method is understandable by the client.
For example,
Accept-Encoding: gzip
The `Accept-Encoding` header is usually attached with a request to the server, indicating which encoding method is understandable by the client.
For example,
Accept-Encoding: gzip
๐ Authorization
As the header name suggests, the `Authorization` request header is used to pass the credentials so the server can authenticate the client.
For example,
Authorization: Basic dgfhWUytzgdfhgSYG
As the header name suggests, the `Authorization` request header is used to pass the credentials so the server can authenticate the client.
For example,
Authorization: Basic dgfhWUytzgdfhgSYG
๐ Accept-Language
The `Accept-Language` request header is used to describe the language the client understands.
For example,
Accept-Language: en-US
The `Accept-Language` request header is used to describe the language the client understands.
For example,
Accept-Language: en-US
๐ Content-Type
`Content-Type` representational header specifies the media type of the resource. This header indicates the content type of the returned data when the client didn't mention any content encoding.
For example,
Content-Type: text/html; charset=UTF-8
`Content-Type` representational header specifies the media type of the resource. This header indicates the content type of the returned data when the client didn't mention any content encoding.
For example,
Content-Type: text/html; charset=UTF-8
๐ Content-Location
`Content-Location` header indicates the alternate location for the response. It is used when an API can return data in different formats depending on the `Accept` header.
For example,
Content-Location: /examples/foo.json
Content-Location: /examples/foo.xml
`Content-Location` header indicates the alternate location for the response. It is used when an API can return data in different formats depending on the `Accept` header.
For example,
Content-Location: /examples/foo.json
Content-Location: /examples/foo.xml
๐ Content-Encoding
The `Content-Encoding` header compresses the message data or payload.
For example,
Content-Encoding: gzip
The `Content-Encoding` header compresses the message data or payload.
For example,
Content-Encoding: gzip
๐ Content-Length
As the header name suggests, it indicates the resource or message body size in bytes. It can be used with both requests and responses.
For example,
Content-Length: 148
As the header name suggests, it indicates the resource or message body size in bytes. It can be used with both requests and responses.
For example,
Content-Length: 148
๐ Content-Language
`Content-Language` indicates the human logical language of the response. This header is used to deliver resources in multiple languages so that users can choose their preferred language.
For example,
Content-Language: en-US
`Content-Language` indicates the human logical language of the response. This header is used to deliver resources in multiple languages so that users can choose their preferred language.
For example,
Content-Language: en-US
๐ Cache-Control
`Cache-Control` header is used as a caching mechanism for both the request and response.
We can pass several directives(values) with this header.
For example,
Cache-Control: max-age
`Cache-Control` header is used as a caching mechanism for both the request and response.
We can pass several directives(values) with this header.
For example,
Cache-Control: max-age
With that said, this is pretty much it for this thread.
Follow @Rapid_API for more quality content related to API development. ๐
Follow @Rapid_API for more quality content related to API development. ๐
Loading suggestions...