Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 14, 2023 06:34 pm GMT

All about APIs

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

  1. Accept
    Media types/data types are accepted by the server.

  2. Content-type
    This can be used both by clients and servers to identify
    the format of the data in their request or response.

  3. Accept-encoding
    This provides meta-information such as the encoding method
    client can understand.

  4. Host
    It specifies the domain name. This means information such
    as the host and the port.

  5. Authorization
    This is used to pass the credentials (such as information,
    keys or tokens) primarily to let the server authenticate
    the request.

  6. Access-control-allow-origin
    This is to restrict the origin which tries to fetch the
    resource.

  7. Accept-language
    Helps in determining the detail that client is accepting
    the response in the mentioned language.

  8. Access-control-allow-methods
    This helps in knowing which methods are allowed to access
    the cross origin resources.

Http_Calls

Http Request Methods

  1. Get
    The Get method is the most common of all these request
    methods. It is used to fetch the resources from the
    server.

  2. 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.

  3. Put
    The put method is used to change data already present in
    the resource collection.

  4. 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.

  5. 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.


Original Link: https://dev.to/shishsingh/all-about-http-calls-4273

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To