Net.HTTP
HTTP's protocol values: methods, statuses, header fields, URLs, requests, and the bodies and responses that go with them, shared by the HTTP/1 codec, the client and the server. Nothing here opens a connection.
import Net.HTTP (..)
import Net.HTTP.MediaType as MediaType
let r = withHeaders(request(GET, "https://api.example.com/users/1"),
field(Accept, MediaType.json))
This module gathers the types, their constructors and the classes, so that
one import brings what a program names and matches on. The functions of
each type are in that type's own module, imported under its name:
Net.HTTP.HeaderName for HeaderName.parse, Net.HTTP.Headers for
Headers.get, Net.HTTP.Status for Status.fromCode, and likewise
HeaderValue, MediaType, Method, Credentials, Cookie, Token,
HTTPURL, Limits and URL. Their names (parse, get, add) would
collide with each other's here, and with the Prelude's. The exceptions are
request, field and withHeaders, which build a request; newPOST,
newPUT, newPATCH and newExtension, which make a method that carries
a body; receive, limited, unbounded and trailers, which read an
Incoming body; contentLength, host, upgradeRequested and
acceptsTrailers, which read the reserved fields of a received request;
and body, stream, statusOnly, noContent, notModified, switch
and relay, which build a server's response: a program names them as often
as it names a method. The server itself is Net.HTTP.Server.
The client is Net.HTTP.Client, imported on its own: it links OpenSSL,
which a program that only handles HTTP values has no need of.
The rules come from HTTP's CVEs. Values are validated strictly when they are made, whether a program writes them or they arrive: no CR, LF or NUL in any of them, and nothing repaired. The fields that frame and route a message -- Content-Length, Transfer-Encoding, Host and the rest -- have no name a program can write, because the library writes them.