Http module

expect_header

procedureextensionexperimental2 overloadsSource

The response has the header, with exactly this value (any case in the name). For Content-Type a value without parameters matches the media type: "application/json" accepts application/json; charset=utf-8.

Example
hello :: () -> string {
    return "hello";
}

main :: () {
    app: App;
    defer free_app(*app);

    get(*app, "/hello", hello);

    api := test_client(*app);

    response, _ := get(api, "/hello");
    defer close(*response);

    assert(expect_header(response, "Content-Type", "text/plain"));
}

Doesn't run in the browser (skipped on wasm).

expect_header :: (
    response: Client_Response,
    name: string,
    value: string,
    loc := #caller_location
) -> bool

Parameters

response: Client_Response
name: string
value: string
loc := #caller_location

Returns

bool
expect_header :: (
    response: Client_Response,
    name: string,
    loc := #caller_location
) -> bool

The response has the header, whatever its value.

Parameters

response: Client_Response
name: string
loc := #caller_location

Returns

bool
Example
hello :: () -> string {
    return "hello";
}

main :: () {
    app: App;
    defer free_app(*app);

    get(*app, "/hello", hello);

    api := test_client(*app);

    response, _ := get(api, "/hello");
    defer close(*response);

    assert(expect_header(response, "Content-Length"));
}

Doesn't run in the browser (skipped on wasm).

See also