HTTP Request Structure, Web
What is HTTP?
HTTP is the abbreviated form of Hypertext Transfer Protocol. The structure provides the path between the requests received from the web browser or client and the responses received from the web servers. The data such as HTML documentations, images, videos, query results are delivered by HTTP using TCP/IP (Transmission Control Protocol/Internet Protocol) on the World Wide Web. Although various ports are used, the commonly used port is TCP 80.
HTTP is a protocol that provides the communication of the web browsers and servers in a common language. Requests and responds are performed by following language rules specified by HTTP.
HTTP request consists of 4 fundamental elements: A request line, zero or more header (General|Request|Entity) fields followed by CRLF, and a space preceding the CRLF (indicating the end of the header fields) and optionally a message body.
The request line specifies the method first which is written with uppercase letters. These methods in HTTP/1.1 version are GET, POST, PUT, HEAD, DELETE, PATCH, and OPTIONS.
Request URI follows the chosen method in the request line. The purpose of the Uniform Resource Identifier recognizes the resource of the request target. Then, HTTP version is specified.
GET /test.html HTTP/1.1
POST /index.html HTTP/1.1
Secondly, the request header fields give some additional information about the request. Some significant headers are:
- General headers can be applied to both request and response messages.
- Client Request headers can be applied to request messages.
- Server Response headers can be applied to response messages.
- Entity headers can be applied to meta information about the entity body or the resource that identifies in request.
An example of request:
GET /hello.htm HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.image4.io Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive