Http: Difference between revisions

From wikinotes
Line 54: Line 54:
</source>
</source>
</blockquote><!-- Requests/Response Line -->
</blockquote><!-- Requests/Response Line -->
== Header Lines ==
<blockquote>
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
<source lang="bash">
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>
</source>
</blockquote><!-- Header Line -->
</blockquote><!-- HTTP Protocol Anatomy -->


= HTTP Cookies =
= HTTP Cookies =

Revision as of 13:40, 18 September 2021

TODO:

clean this up

TODO:

add section for headers, CORS, Content Security Policy, etc

Documentation

MDN HTTP overview https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview
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.0

response

# <http version>  <status-code>  <status-phrase>
HTTP/1.0          200            Ok
HTTP/1.0          404            Not Found

HTTP Cookies

See http cookies.

Notes

http protocol
http headers
http statuses
http cookies