Import std.net.http.client
Body
struct
Public Struct Body
What a request sends: its bytes, and what they are, as its Content-Type header says unless the request's headers say it themselves. Panics for a contentType a header's value can't be, as Headers.Add does.
Examples
Local form = Body.Form({"name": "Ada Lovelace", "age": "36"})
Expect(form.ContentType == "application/x-www-form-urlencoded")
Expect(String.FromUtf8(form.Bytes) == "name=Ada%20Lovelace&age=36")
Expect(Body.Text("hi").ContentType == "text/plain; charset=utf-8")std/net/http/client.fb, line 93
-
Its bytes.
-
Its Content-Type, or Null to send none.
-
@PanicsAtCaller Public New(bytes: UInt8[], contentType: String? = "application/octet-stream")constructor #A Body of
bytes, which are whatcontentTypesays. -
@PanicsAtCaller Public Static Method Text(text: String, contentType: String = "text/plain; charset=utf-8"): Bodystatic method #text's UTF-8, as plain text unlesscontentTypesays another kind. -
JSON's text, as application/json.
-
A form's
fields, in their order, as application/x-www-form-urlencoded: each name and value with each byte but the letters, digits, '-', '.', '_', and '~' as %XX, which servers read as they read a browser's '+' for a space, each pair as name=value, and '&' between them.
Report an issue with this page or with FutureBlitz on GitHub.