Structure of an HTTP Request

The HTML that creates the web page that you see is only a part of what gets transferred from the server to the browser. Everything from the doctype to the </html> tag makes up the body of the HTTP transmission. The HTTP transmission also has a head portion that precedes this body. Note that while the HTML has its own head and body sections these are both a part of the body of the HTTP transmission as they both form a part of the actual web page content even though only the body of the HTML is the only part to display anything inside the browser viewport.

So basically an HTTP transmission consists of an HTTP head section followed by an HTTP body section with that body section itself containing an HTML head section followed by an HTML body section. At least that's what you get in the body with a regular request for a web page. The body can in fact contain anything at all and if the request is being made from JavaScript then you will be more likely to be sending XML, JSON or even plain text as the body of the response rather than HTML.

What is contained in the head section of the HTTP transmission and in fact whether the request has a body section at all depends on what type of HTTP request that was sent to the server in the first place. For example if the HTTP request is a HEAD request then the response will not have a body section.

All HTTP requests actually originate in the browser and are sent to the server for actioning. Many of the values in the headers are there to supply the information to the server as to what it is that is being requested while others are intended primarily to provide information back to the browser. In some cases the information gets passed back and forth between the browser and server in the HTTP headers.

The following are standard HTTP headers that can be sent from the browser to the server:

The first thing returned from the server in the HTTP header is a status field that indicates the status of the request - for example a status of 200 indicates that the call was successfully made and the called server process was run (whether that did what you wanted or not is a separate issue). following are standard HTTP headers that can be returned from the server to the browser.

There are no limits defined in the standards as to how many headers that an HTTP request or response can contain or how big the head section can be but most browsers and web servers do have limits on the size of individual headers and the maximum number of headers that the request/response can contain.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow