http - HTTP/1.1 client and server, in the shape of Go's net/http.
A client sends a request and reads a response; a server accepts connections and hands each one to a handler, which is any function of (w, r). Headers are kept in a map whose keys are lowercase, so looking one up doesn't depend on how the other side chose to spell it.
What is not here: TLS, chunked transfer encoding, keep alive. Every connection carries one exchange and is closed.
¶StatusOK = 200valuesource
¶StatusCreated = 201valuesource
¶StatusAccepted = 202valuesource
¶StatusNoContent = 204valuesource
¶StatusMovedPermanently = 301valuesource
¶StatusFound = 302valuesource
¶StatusSeeOther = 303valuesource
¶StatusNotModified = 304valuesource
¶StatusTemporaryRedirect = 307valuesource
¶StatusPermanentRedirect = 308valuesource
¶StatusBadRequest = 400valuesource
¶StatusForbidden = 403valuesource
¶StatusNotFound = 404valuesource
¶StatusMethodNotAllowed = 405valuesource
¶StatusRequestTimeout = 408valuesource
¶StatusConflict = 409valuesource
¶StatusPayloadTooLarge = 413valuesource
¶StatusUnsupportedMediaType = 415valuesource
¶StatusTooManyRequests = 429valuesource
¶StatusInternalServerError = 500valuesource
¶StatusNotImplemented = 501valuesource
¶StatusBadGateway = 502valuesource
¶StatusGatewayTimeout = 504valuesource
¶StatusText = fn(code)source
StatusText returns the reason phrase of a status code, empty when the code is not one of the known ones.
¶MethodGet = "GET"valuesource
¶MethodHead = "HEAD"valuesource
¶MethodPost = "POST"valuesource
¶MethodPut = "PUT"valuesource
¶MethodPatch = "PATCH"valuesource
¶MethodDelete = "DELETE"valuesource
¶MethodOptions = "OPTIONS"valuesource
¶ParseURL = fn(rawurl)source
ParseURL takes a URL apart: Scheme, Host with its port, Path, RawQuery and Query, which is the query string already split into a map.
¶Scheme = schemevaluesource
¶Hostvaluesource
¶Hostname = net.SplitHostPort(u.Host).Hostvaluesource
¶Path = pathvaluesource
¶RawQuery = queryvaluesource
¶Query = ParseQuery(query)valuesource
¶ParseQuery = fn(raw)source
ParseQuery reads a query string into a map. A key without a value maps to the empty string, the way an empty field does.
¶Escape = fn(s)source
Escape writes a string so that it can travel inside a URL.
¶HeaderGet = fn(h, name)source
HeaderGet returns the value of a header, or an empty string.
¶HeaderSet = fn(h, name, value)source
¶NewRequest = fn(method, url, body)source
NewRequest builds a request. Body may be null for the methods that carry none.
¶Method = if method == null { MethodGet } else { strings.ToUpper(method) }valuesource
¶URL = urlvaluesource
¶Path = u.Pathvaluesource
¶RawQuery = u.RawQueryvaluesource
¶Query = u.Queryvaluesource
¶Host = u.Hostvaluesource
¶Header = newHeader()valuesource
¶Body = if body == null { "" } else { string(body) }valuesource
¶NewClient = fn(timeout)source
NewClient returns a client. Timeout is in milliseconds and may be null.
¶Timeout = if timeout == null { 30000 } else { timeout }valuesource
¶Do = fn(req)source
Do sends a request and returns the response.
¶Proto = parts [0]valuesource
¶StatusCode = codevaluesource
¶Status = if len(parts) > 2 { parts [2] } else { StatusText(code) }valuesource
¶Header = readHeaders(r)valuesource
¶Body = bodyvaluesource
¶Get = fn(url)source
¶Post = fn(url, contentType, body)source
¶Head = fn(url)source
¶DefaultClient = NewClient(null)valuesource
¶Timeout = if timeout == null { 30000 } else { timeout }valuesource
¶Do = fn(req)source
Do sends a request and returns the response.
¶Proto = parts [0]valuesource
¶StatusCode = codevaluesource
¶Status = if len(parts) > 2 { parts [2] } else { StatusText(code) }valuesource
¶Header = readHeaders(r)valuesource
¶Body = bodyvaluesource
¶Get = fn(url)source
¶Post = fn(url, contentType, body)source
¶Head = fn(url)source
¶Get = fn(url)source
¶Post = fn(url, contentType, body)source
¶Head = fn(url)source
¶NewServeMux = fn()source
NewServeMux returns a multiplexer. A pattern ending in "/" matches every path below it, anything else matches exactly, and the longest pattern that matches wins, as in Go.
¶Handle = fn(pattern, handler)source
¶HandleFunc = fn(pattern, handler)source
¶Handler = fn(path)source
Handler returns the handler for a path, or null when none matches.
¶ServeHTTP = fn(w, r)source
¶DefaultServeMux = NewServeMux()valuesource
¶Handle = fn(pattern, handler)source
¶HandleFunc = fn(pattern, handler)source
¶Handler = fn(path)source
Handler returns the handler for a path, or null when none matches.
¶ServeHTTP = fn(w, r)source
¶Handle = fn(pattern, handler)source
¶HandleFunc = fn(pattern, handler)source
¶NotFound = fn(w, r)source
NotFound is the handler for a path nothing was registered for.
¶Error = fn(w, msg, code)source
Error replies with a message and a status code.
¶Redirect = fn(w, r, url, code)source
Redirect replies with a redirect to url.
¶NewServer = fn(addr, handler)source
NewServer returns a server. Handler is a mux or any function of (w, r).
¶Addr = addrvaluesource
¶Handler = if handler == null { DefaultServeMux } else { handler }valuesource
¶ListenAndServe = fn()source
ListenAndServe accepts connections until Close is called, one tau routine per connection so that a slow client holds up nobody.
¶Close = fn()source
¶ListenAndServe = fn(addr, handler)source
ListenAndServe serves handler on addr until something goes wrong.
¶Addr = addrvaluesource
¶Handler = if handler == null { DefaultServeMux } else { handler }valuesource
¶ListenAndServe = fn()source
ListenAndServe accepts connections until Close is called, one tau routine per connection so that a slow client holds up nobody.