HTTP
- Tags
- networking
An application layer protocol used for communication between web-browsers and web-servers.
HTTP defines several request methods including GET, POST, HEAD, PUT, DELETE, TRACE, etc. For a comprehensive list with descriptions for the purpose of each method see here.
Requests & Responses
A HTTP request is a plain-text query, shown below, with each line ending with carriage-return/line-feed. Requests are defined with the first line showing the request method, path and then the HTTP protocol version. The following lines specify HTTP headers (key value pairs) that describe the request. Then any data after a blank line is the request content.
A HTTP response follows the same form as a request.
Some HTTP headers have special values. The set-cookie
response header makes the
client store some data and re-transmit it on any subsequent requests. The
content-type
and content-length
headers describe the content of the request and
response.
Ordinarily for GET requests any method data (AKA params) are specified in the path
itself (in the form described in URL). Alternatively one can place this data as the
requests content and set the content-type
field to application/x-www-form-urlencoded
.
POST requests in particular transmit the request data in the content, sometimes as JSON, and is generally used for more secure communications.
[see page 18, GET vs POST]
GET | POST | |
---|---|---|
Can be cached? | Yes | No |
Can be bookmarked? | Yes | No |
Tracked in browser history | Yes (dangerous!) | No |
Have a maximum length | Yes | No |