Messages For HTML Pages, Images, Scripts and Styles Sheets. Web Servers
Messages For HTML Pages, Images, Scripts and Styles Sheets. Web Servers
Introduction
The HTTP request message has a simple text based structure. For
example, here is the the request message sent by Internet Explorer (IE) for
this web page:
Accept: */*
Accept-Language: en-gb
Host: www.httpwatch.com
Connection: Keep-Alive
The first line of the message, known as the request line, contains:
The relative URL of the resource or a full URL if you are using an HTTP
proxy
The version of HTTP that is being used. Most modern HTTP clients and
servers will use HTTP version 1.1 as defined in RFC 2616.
The web server's response message has a similar structure, but is followed
by the contents of the HTML page:
HTTP/1.1 200 OK
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
Expires: -1
Content-Length: 14990
The first line, or status line, returns a status code from the server that
indicates whether the request was successful (see 3. Status codes and
errors). The value 200 is returned if the request was processed correctly
and content is being returned to the client.
The next eight lines of text contain header values that describe the data
and the way in which it is being returned to the client. For
example, Content-Type has the value text/html because the page is in
HTML format. The response headers are terminated with a double CRLF
(carriage return, line feed) and are followed by the contents of the
requested resource.
Images are not directly embedded into web pages. Instead, they are
specified as separate resources using HTML <img> tags:
Example 1
Clicking the Refresh button will redisplay this web page by sending HTTP
requests to download the HTML of the page and its associated styles sheets and
images.
2. HTTP Headers
Headers are name/value pairs that appear in both request and response
messages. The name of the header is separated from the value by a single
header is to supply the web server with information about the type of
browser making the request. A complete definition of this and other
specification.
the HTTP response message from this web server set an X-AspNet-
Example 2
Clicking the Get Current Time button requests an updated copy of the following
image:
The Headers tab will show two lists of headers; the one on the left
is for the request message and the one on the right for the response
message.
2.1 Request Headers
and control how content is returned. If you are using IE, you will have seen
Accept:*/*
This header indicates that the browser will accept all types of content.
Accept-Language: en-gb
Connection: Keep-Alive
Host: www.httpwatch.com
HTTP/1.1 requires that the host name is supplied with every request so that
This is supplied by the browser to indicate if the current request was the
result of a link from another web page. The server may use this information
to gather usage statistics or to track which web sites have links to a page.
content is being returned and how it should be handled. If you are using IE,
you will have seen the following headers returned with the image in
Example 2:
Cache-Control: no-cache
This header indicates whether the resource may be cached by the browser
Content-Length: 2748
This header contains the length in bytes of the resource (i.e. the gif image)
Content-Type: image/gif
out of date. The value -1 indicates that the content expires immediately and
Pragma: no-cache
Server: Microsoft-IIS/6.0
X-AspNet-Version: 4.0.30319
The web server is running ASP.NET 4.0
X-Powered-By: ASP.NET
2. The browser could not connect to the web server. This may happen if
the web server is not running or is listening on the wrong port.
HTTP status codes are returned by web servers to describe if and how a
request was processed. The codes are grouped by the first digit:
1xx - Informational
Any code starting with '1' is an intermediate response and indicates that the
server has received the request but has not finished processing it. For
example, IIS initially replies with 100 Continue when it receives a POST
request and then with 200 OK once it has been processed (See 6.
Methods)
2xx - Successful
These codes are used when a request has been successfully processed.
For example, the value 200 is used when the requested resource is being
returned to the HTTP client in the body of the response message.
3xx - Redirection
Codes starting with a '3' indicate that the request was processed, but the
browser should get the resource from another location. Some examples
are:
302 The requested resource has been temporarily moved and the browser
should issue a request to the URL supplied in the Location response
header. (See 7. Redirection)
304 The requested resource has not been modified and the browser should
read from its local cache instead. The Content-Length header will be
zero or absent because content is never returned with a 304 response
(See 5. Caching for more detail)
401 Anonymous clients are not authorized to view the requested content and
must provide authentication information in the WWW-
Authenticate request header. (See 10. Authentication for more detail)
A status code starting with the digit 5 indicates that an error occurred on
the server while processing the request. For example: