Import with #import "std/net_http".

HttpHeader :: struct { name: string; value: string; }

Network transport is an explicit host capability. The host adds a Bearer Authorization header when token is nonempty. It must not log that token. The request and response records have the same meaning in native targets and portable bundles.

HttpRequest :: struct { method: string; url: string; token: string; accept: string; content_type: string; body: string; headers: []HttpHeader; }
HttpResponse :: struct { status: s32; body: string; error: string; }
Send :: (request: HttpRequest) -> HttpResponse

Needs a host capability.

Source ↗ · All modules