---
# System prepended metadata

title: RFC

---

# RFC

## Request

HEAD/GET/POST URI HTTP/1.1\r\n
start line\r\n
headers\r\n
\r\n
body(optional)

## Parsing

start line $\to$ struct (to determine whether the message is a request or a response)
headers $\to$ hash table
attributs: Method uri protocol-version

Request::parse
    `if not post/get/head/ throw response catch ?`
    `501 not implemented exception`
    
request = method + " " + request_target + " " + protocol_ver + crlf (\r\n)
    
Request::response
Même fonction pour HEAD et GET + booléen pour déterminer si

response catch

invalid request line = err 400 or err 301 without autocorrecting

method longer than any implemented = err 501 or 414

header case insensitive

header : no restriction

Pas d'espace entre le start line et le début des headers sinon stop le parsing.