HTTP Request Message

HTTP Request


The request (most always a get) really has only three parts...

  • The request line (the first line),
  • the Header Fields,
  • and the Payload (message)

Example:

GET /kennyl HTTP/1.1
Host: 24.10.2.100:6443
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
DNT: 1
Connection: keep-alive
Cache-Control: max-age=0"

The First lin is the Request Line followed by the header fields. Since this request is a GET... It traditionally has no payload.

CREATED 2012-07-17 06:23:45.0

00-14-A4

UPDATED 2020-07-03 07:34:43.0

The Request Line


The request line has three parts, each seperated by a space or spaces: Example
  • The method
  • the Request URI,
  • the protocol (HTTP/1.01)
GET /kennyl HTTP/1.1

The method is GET, the path to execute that method is /kennyl and the protocol is HTTP/1.1. The default entity located at /kennyl will be rendered by the server.

The Request Line is terminated by a carrage return and a line feed (CR/LF). No other CR or LF are allowed on this line.

CREATED 2012-07-17 06:43:38.0

00-14-A8

UPDATED 2020-07-03 07:34:44.0

Method


The Method is the action the requestor wants to enact. Methods are directed to the resource located at the Request URI. RFC 2616 supports these methods:
  • GET - Retrieve whatever information in the form of an entity served up by resource
  • HEAD - Like GET but return only the header information the resource renders
  • POST - requests an enclosed entity be processed by the resource
  • PUT - request that something be added to the resource
  • DELETE - requests that an entity be deleted from the resource
  • TRACE - sends back a copy of the request message
  • CONNECT - used for tunneling

To be a real server, the GET and HEAD methods must be supported. Otherwise the server can respond to the requestor in one of three ways... 1: give them what they want... 2: return a status code of 501 (method not implemented) or 3: return a status code 405 (method not allowed):

CREATED 2012-07-17 08:43:00.0

00-14-AA

UPDATED 2020-07-03 07:34:44.0

Request URI


The Request URI indicates which resource the method applies to. The Request URI has four options:
  • * - Action is intended for the server
  • absoluteURI - required when the request is being made to a proxy, however, it is a must for a server to accept.
  • abs_path - most common, identifies the path to the resource, if it were appended to the end of the HOST header field.
  • authority - Used with the CONNECT method.

CREATED 2012-07-17 08:44:08.0

00-14-AB

UPDATED 2020-07-03 07:34:45.0

Protocol


The protocol is which version of HTTP is being used. HTTP/1.1 or HTTP/1.0.

CREATED 2012-07-17 08:44:40.0

00-14-AC

UPDATED 2020-07-03 07:34:46.0

The Header Fields


Header fields are transmitted in name/value pairs seperated by a semi-colon ":". Unlike the Request Line, spaces (32) are ignored in this section. Names are on the left and values are on the right. The names are easy - they are simple names.

Values can be more difficult because there can be more than one value for each field.

Single Value:

Host: www.kenny-l.com

This field has only one value, the host the request is being sent to, "www.kenny-l.com" The Field name is "Host" and the value is "www.kenny-l.com"

Multiple Values:

Accept: text/html,application/xhtml-xml,application/xml;q=0.9,*/*;q=0.8

CREATED 2012-07-17 07:57:10.0

00-14-A9

UPDATED 2020-07-03 07:34:47.0

Responses...


The ReadyState of the request (response) is a number from 1 to 4

  • 1 - after the request object has been open sucessfully
  • 2 - adter the send is invoked and the response is received
  • 3 - response content is loading
  • 4 - response content is loaded.

The listener must be invoked before any state has changed in order to capture the change.

var reqObject = new XMLHttpRequest(); reqObject.onreadystatechange =
function{
 if(reqObject.readyState == 1){
  alert("Request Object Open");
 }else if(reqObject.readyState == 2){
  alert("Request Object Sent");
 }else if(reqObject.readyState == 3){
  alert("Receiving ResponseObject");
 }else if(reqObject.readyState == 4){
  alert("Request Object Received");
 }
 reqObject.open;   <-- the ready state is 1
 reqObject.send(null);   <-- the readyState is 2

CREATED 2012-09-03 19:16:15.0

00-16-5F

UPDATED 2020-07-03 07:35:01.0

Knowledge

Request Methods
L
I
N
K
S

DBID: db.wam

Page Server: Ithica

©2012 Leistware Data Systems

      Hello anonymous