Net.HTTP.Body
What a client can send as a request body, and the methods that carry one.
let form = withHeaders(request(newPOST("a=1&b=2"), url), field(ContentType, MediaType.formURLEncoded))
send(c, form, Duration.seconds(10), use)
File.use(File.openRead(path), fun(f) {
let upload = withHeaders(request(newPUT(f), url), field(ContentType, MediaType.octetStream))
send(c, upload, timeout, use)
})
The client never picks a media type: a request has the Content-Type
its headers give it, or none.
A request a client sends is a ClientRequest Payload: its body, if its
method has one, is the client's one body type, so request(GET, url)
needs no annotation. newPOST, newPUT, newPATCH and newExtension
take any Body and make the Payload from it. A proxy passes on a
request it received with map(req.method, payload).
Sending again. Replay marks a body that can be sent again whole:
String, Buffer and File, the last read from offset 0 each time. The
client sends a request again (its one retry, a 307 or 308 redirect) only
if its body is one. An Incoming is passed on as it arrives, and a
Stream written as it goes; each is sent once. A program that must read a
body before sending it, to sign it, asks for Replay.
Trailers. A Stream's function returns the fields to send after the
body, and a relayed Incoming sends the trailers it arrived with. Only a
chunked body has trailers, so a Stream of LengthKnown length that
returns any fails the request with UnframedTrailers.
A value a client can send as a request body.
A body that can be sent again whole.
Returns a POST carrying b.
Returns a PUT carrying b.
Returns a PATCH carrying b.
Returns the extension method name carrying b.
A string's UTF-8 bytes.
A buffer's window, as it is when the request is made.
A file's contents, from offset 0, with the length stat gives when the
request is sent.
A body that arrived, passed on as it is read, with no limit of its own, and its trailers after it.
A body written as it is sent, with the trailers its function returns.