Modules

std.http

HTTP method, body-length, client/server metadata, and TLS-boundary helpers.

Status

Runnable today:

APIReturnNotes
std.http.parseMethod(text)HttpMethodParses a small HTTP method token.
std.http.client(net)HttpClientCreates hosted client metadata from a network capability.
std.http.server(net, address)HttpServerCreates hosted server metadata from a network capability and address.
std.http.bodyLen(bytes)usizeReports body byte length without allocation.
std.http.tlsBoundary()StringNames the platform or C-library TLS boundary.

Metadata labels:

  • effects: net or memory
  • allocation behavior: no allocation
  • target support: parsing and body length are target-neutral; client/server require a net-capable target
  • error behavior: infallible helpers
  • ownership notes: HTTP helpers borrow network capability metadata
  • example: conformance/native/pass/std-net-http-breadth.0

Example

pub fun main(world: World) -> Void raises {    let net = std.net.host()    let addr = std.net.address("localhost", 8080_u16)    let _client = std.http.client(net)    let _server = std.http.server(net, addr)    let method = std.http.parseMethod("GET")    if method == std.http.parseMethod("GET") &&        std.http.bodyLen(std.mem.span("body")) == 4 {        check world.out.write("http ok\n")    }}

Design Notes

std.http currently exposes parsing and hosted metadata helpers. It does not provide a request/response runtime in the current public surface.