HTTP MessageHTTP Message is used to show how data is exchanged between the client and the server. It is based on client-server architecture. An HTTP client is a program that establishes a connection to a server to send one or more HTTP request messages. An HTTP server is a program that accepts connections to serve HTTP requests by sending an HTTP response messages. The HTTP Messages can be classified as follows: Message TypeHTTP message consists of an initial request line and an initial response line. Format: 1) Initial Request Line The initial line is different for the request and for the response. A request-line consists of three parts: a method name, requested resource's local path, and the HTTP version being used. All these parts are separated by spaces. Syntax: Here,
2) Initial Response Line The initial Response line is also known as the status line. It also has three parts: the HTTP version, a response status code that gives the result of the request, and the English reason phrase describing the status code. Example: Here, The HTTP version of the response line and request line are the same as "HTTP/x.x". Message HeadersThe Message header provides information about the request and response. It also provides information about the object which is sent in the message body. Message Headers are of four types:
All the above headers follow the same generic format. Each of the header fields consists of a name followed by a colon and the field values as follows: Message BodyThe message body of an HTTP message is used to carry the entire body associated with the request and response. The message-body differs from the entire-body only when a transfer-coding has been applied, as indicated by the Transfer-Encoding header field. Syntax Transfer-Encoding MUST be used to indicate any transfer-codings which is applied by an application to ensure safe and proper transfer of the message. Transfer-Encoding is a property of the message. Message LengthThe transfer-length of a message is the length of the message-body, and it appears in the message. In a message, when a message body is allowed, and Content-Length is given, its field value MUST exactly match the number of OCTETs in the message-body. When an invalid length is received and detected, the HTTP/1.1 user agents MUST notify the user. General Header FieldsSome header fields have the applicability for both the request and response messages. These header fields apply only when the message is transmitted. Syntax Next TopicHTTP Request |