

This helps in parsing the response at the client-side. Indicates the media type (text/html or text/JSON) of the response sent to the client by the server. This tells the server about which character sets are acceptable by the client. Often sent along with a response code of 401, which means ‘unauthorized’. This is sent by the server if it needs a form of authentication before it can respond with the actual resource being requested. AuthorizationĬarries credentials containing the authentication information of the client for the resource being requested.

Let’s learn about what other header options are available. We will add 2 of these to our server for success and the wrong path. Refer to this sheet for detailed info on all the available status codes.

For example, a page not found response has a status code 404 and a successful request has a status code 200. The response has a header and status code that provides info about the response. We finally created an echo server that accepts the message and returns them to the client. You can check this by entering the wrong url or simply not pass any message. We also added an else block that will take care of requests when the page url is wrong or the message query parameter is not present.
