HTTP is a protocol, a set of rules for accessing resources on the web. Resources could be anything from HTML files, data from a db, photos, text and so on. These resources are made available to us via an API and we make requests to this API via the HTTP protocol
Content-Type: This header specifies the media type of the resource being sent. For example, application/json
indicates that the data is in JSON format, while application/x-www-form-urlencoded
is used for form data. It helps the server or client understand how to process the incoming or outgoing data.
Authorization: This header is used to pass credentials for authenticating the client with the server. For instance, it might include a token (like a JWT) or basic authentication credentials (username and password encoded in Base64).
Cache-Control: This header directs caching mechanisms on how to handle responses. It can specify whether a response can be cached, how long it can be cached, and under what conditions it should be revalidated. For example, no-cache
means that the response should not be cached.
CORS Headers: Cross-Origin Resource Sharing (CORS) headers control how resources on a web page can be requested from another domain. Key headers include:
Access-Control-Allow-Origin
: Specifies which domains are allowed to access the resource.
Access-Control-Allow-Methods
: Lists the HTTP methods (GET, POST, etc.) allowed when accessing the resource.
JSON: JavaScript Object Notation is a lightweight data interchange format that's easy for humans to read and write and easy for machines to parse and generate. It uses key-value pairs and is widely used in APIs.
Form Data: This format is often used for submitting forms on websites. It encodes data as key-value pairs in a way that is easy for servers to process, typically using application/x-www-form-urlencoded
or multipart/form-data
for files.
XML: Extensible Markup Language is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It uses tags to structure data but is generally more verbose than JSON.