Esc

decode_metadata

procedureextensionsince 0.36.1Source
  • macOS: decode_metadata works on macOS
  • Linux: decode_metadata works on Linux
  • Windows: decode_metadata works on Windows
  • Wasm: decode_metadata works on Wasm

Copies application metadata into owned storage. Comma-joined binary values are split before padded/unpadded Base64 decode. Reserved protocol fields are excluded. Release the result with free_metadata, including on an empty result. .

Signature

decode_metadata :: (
    fields: [] Http.Header_Field,
    limit := 64 * 1024
) -> (metadata: [..] Metadata_Entry, ok: bool)
Example↗
Http :: #import "Extensions/Http";

main :: () {
    fields := Http.Header_Field.[
        .{ name = "x-key", value = "value" },
        .{ name = "grpc-status", value = "0" },
    ];
    entries, ok := decode_metadata(fields);
    defer free_metadata(*entries);
    assert(ok && entries.count == 1 && entries[0].name == "x-key"); // grpc-* fields are left out
}

See also