Http
TODO:
clean this up
Documentation
http headers https://en.wikipedia.org/wiki/List_of_HTTP_header_fields
HTTP Protocol Anatomy
The HTTP protocol is composed of requests and responses. At the top of an HTTP message is a header with information about the sender (ex: operating system, character-set, ip-address, port, ...). The header is followed by the body of the message (called a resource). Resources are generally either files, or responses from server-side CGI scripts.
Skeleton of HTTP protocol:<initial line, different for request vs. response> Header1: value1 Header2: value2 Header3: value3 <optional message body goes here, like file contents or query data; it can be many lines long, or even binary data $&*%@!^$@> # source: https://www.jmarshall.com/easy/http/Request/Response Line
This is the first line in the header, and it varies slightly depending on the type of method the HTTP message is using.
request
# <method> <local path of file> <http version> GET /path/to/file/index.html HTTP/1.0response
# <http version> <status-code> <status-phrase> HTTP/1.0 200 Ok HTTP/1.0 404 Not FoundHeader Lines
Header lines are a series of key/value pairs generally with information about the sender. keypairs are separated by <CRLF>, newlines beginning with whitespace are continuations of the previous line.
Examples of information:
- ip addr/port
- operating system
- browser
- page that linked to this one
HTTP/1.0 200 Ok From: user@email.com User-Agent: some-webbrowser/1.0 Content-Type: application/x-www-form-urlencoded <html> <body> ... </body> </html>
HTTP Status Codes
HTTP status codes are classified by their leftmost number:
1xx ## notification only 2xx ## success 3xx ## redirect client to another URL 4xx ## error on the client's part 5xx ## error on the server's part
HTTP Cookies
See http cookies.