This reading explores the contents of HTTP requests and responses in more depth.
Every HTTP request begins with the request line.
This consists of the HTTP method, the requested resource and the HTTP protocol version.
GET /home.html HTTP/1.1
In this example, GET is the HTTP method, /home.html is the resource requested and HTTP 1.1 is the protocol used.
HTTP methods indicate the action that the client wishes to perform on the web server resource.
Common HTTP methods are:
HTTP Method | Description |
---|---|
GET | The client requests a resource on the web server. |
POST | The client submits data to a resource on the web server. |
PUT | The client replaces a resource on the web server. |
DELETE | The client deletes a resource on the web server. |
After the request line, the HTTP headers are followed by a line break.
There are various possibilities when including an HTTP header in the HTTP request. A header is a case-insensitive name followed by a**:** and then followed by a value.
Common headers are:
Host: example.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: */*
Accept-Language: en
Content-type: text/json