HTTP Request Message Structure


REST services are accessed by standard HTTP requests. A complete HTTP request consist of the request-line, the message-headers, and the entity-body. Between the message-headers and entity-body is an empty line contains only carriage returns and line feeds.

The request-line begins with a method token, followed by the Request-URI and the protocol version, and ending with CRLF. The elements are separated by SP characters. No CR or LF is allowed except in the final CRLF sequence.

Example: GET /news.asp HTTP/1.1

Header fields are colon-separated name-value pairs in clear-text string format. Message-headers provide information about the request. For instance, Host: http://demo.com:80 indicates the host and number on which the requested resource is hosted. According to HTTP/1.1, the Host header is required. To know more about other message-headers, such as Accept-Charset, Accept-Encoding, Authorization, etc., please refer to RFC194 and RFC2616.

The entity (if any) of an HTTP message is used to carry the data associated with the request, including some request-related parameters. The presence of an entity-body in a request is signaled by the inclusion of a Content-Length or Transfer-Encoding header field in the request's message-headers. The Content-Type header gives the MIME-type of the data in the body.

Here is a complete HTTP request with an entity body:

POST /news.asp HTTP/1.1

Host: demo.com:80

Content-Length: 15

 

[a=1,(b=2,c=3)]

See