This content originally appeared on DEV Community and was authored by Shish Singh
As per the official definition by Mozilla
An HTTP header is a field of an HTTP request or response that passes additional context and metadata about the request or response.
In a simple term client and server can pass the extra bit of information(contextual/meta data) with the request and response using the http headers.
These are further divided into four parts;
Request headers
These are use to send information while making a client to
sever call.Response headers
Contrary to the first one, these are use to send information
while sending the response back to the client from the
server.Representation headers
This holds the information about the body of the response.Payload headers
This is used to hold the information about the payload data.
Commonly used headers
Accept
Media types/data types are accepted by the server.Content-type
This can be used both by clients and servers to identify
the format of the data in their request or response.Accept-encoding
This provides meta-information such as the encoding method
client can understand.Host
It specifies the domain name. This means information such
as the host and the port.Authorization
This is used to pass the credentials (such as information,
keys or tokens) primarily to let the server authenticate
the request.Access-control-allow-origin
This is to restrict the origin which tries to fetch the
resource.Accept-language
Helps in determining the detail that client is accepting
the response in the mentioned language.Access-control-allow-methods
This helps in knowing which methods are allowed to access
the cross origin resources.
Http Request Methods
Get
The Get method is the most common of all these request
methods. It is used to fetch the resources from the
server.Post
The Post method is used to submit the information to the
server. Since, we are submitting the data the post method
often changes the state of the server.Put
The put method is used to change data already present in
the resource collection.Patch
Contrary to put, the patch request method is used to
modify only the necessary part of the data or response.
Simply stating it never modifies the entire response.Delete
As per its name, delete request method is used to delete
the specific resource. It requests that the origin server
delete the resource identified the request URL.
**Resources are datasets in the above statements.
This content originally appeared on DEV Community and was authored by Shish Singh
Shish Singh | Sciencx (2023-04-14T18:34:21+00:00) All about APIs. Retrieved from https://www.scien.cx/2023/04/14/all-about-apis/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.