Explain HTTP Request and Response Message Format

Explain HTTP Request and Response Message Format

Answer:-

HTTP request:

General format of an HTTP request message

▫ The first line of an HTTP request message is called the request line; the subsequent lines are called the header lines.
▫ The great majority of HTTP request messages use the GET method. The GET method is used when the browser requests an object, with the requested object identified in the URL field.
▫ By including the Connection: close header line, the browser is telling the server that it doesn’t want to bother with persistent connections; it wants the server to close the connection after sending the requested object.
▫ This header line is useful because the server can actually send different versions of the same object to different types of user agents.
▫ the Accept-language: header indicates that the user prefers to receive a French version of the object, if such an object exists on the server; otherwise, the server should send its default version.
▫ POST message, the user is still requesting a Web page from the server, but the specific contents of the Web page depend on what the user entered into the form fields.
▫ The HEAD method is similar to the GET method. When a server receives a request with the HEAD method, it responds with an HTTP message but it leaves out the requested object.
▫ The PUT method is often used in conjunction with Web publishing tools.
▫ It allows a user to upload an object to a specific path (directory) on a specific Web server.
▫ The PUT method is also used by applications that need to upload objects to Web servers.
▫ The DELETE method allows a user, or an application, to delete an object on a Web server.

HTTP response:

General format of an HTTP response message

▫ The entity body is the meat of the message—it contains the requested object itself (represented by data data data data data … ).
▫ The Date: header line indicates the time and date when the HTTP response was created and sent by the server.
▫ The Server: header line indicates that the message was generated by an Apache Web server.
▫ The Last- Modified: header line indicates the time and date when the object was created or last modified.
▫ The Content-Type: header line indicates that the object in the entity body is HTML text.
▫ 200 OK: Request succeeded and the information is returned in the response.
▫ 301 Moved Permanently: Requested object has been permanently moved; the new
▫ URL is specified in Location : header of the response message. The client software will automatically retrieve the new URL.
▫ 400 Bad Request: This is a generic error code indicating that the request could not be understood by the server.

▫ 505 HTTP Version Not Supported: The requested HTTP protocol version is not supported by the server.

Leave a Reply

Your email address will not be published. Required fields are marked *