ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
grpcweb.h File Reference

gRPC-Web message framing (PROTOCORE_ENABLE_GRPC_WEB): the zero-heap length-prefixed message builder and parser. More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

gRPC-Web message framing (PROTOCORE_ENABLE_GRPC_WEB): the zero-heap length-prefixed message builder and parser.

THE GOVERNING STANDARD IS NOT AN IETF RFC. gRPC-Web is specified by the gRPC project (CNCF) in grpc/grpc doc/PROTOCOL-WEB.md, layered on the gRPC over HTTP/2 protocol in grpc/grpc doc/PROTOCOL-HTTP2.md. Both are cited below by document and section name. The transport underneath is HTTP, which IS IETF: RFC 9110 and RFC 9112.

PROTOCOL-HTTP2.md "Requests" gives the frame every call here builds or reads:

Length-Prefixed-Message -> Compressed-Flag Message-Length Message
Compressed-Flag -> 0 / 1 ; encoded as 1 byte unsigned integer
Message-Length -> {length of Message} ; 4 byte unsigned integer (big endian)
Message -> *{binary octet}

PROTOCOL-WEB.md "Protocol differences vs gRPC over HTTP2", under "Message framing", reads the 8th (MSB) bit of the 1st gRPC frame byte as the frame type, 0 for data and 1 for trailers, so 10000000b is an uncompressed trailer and 10000001b a compressed one. That trailers frame carries the response status in the body as "Key-value pairs encoded as a HTTP/1 headers block (without the terminating newline)", which is RFC 9112 sec 7.1.2 trailer-section = *( field-line CRLF ) over the RFC 9112 sec 5 field-line = field-name ":" OWS field-value OWS. PROTOCOL-WEB.md "HTTP wire protocols" item 2 requires those names to be lower-case in the last length-prefixed message, and PROTOCOL-HTTP2.md "Responses" names them:

Trailers -> Status [Status-Message] [Status-Details] *Custom-Metadata
Status -> "grpc-status" 1*DIGIT
Status-Message -> "grpc-message" Percent-Encoded

Trailers are the last message of a response, after zero or more data frames.

A Message is an encoded Protobuf message: services/iot/protobuf builds it, this frames it. The media type a response carries it under is application/grpc-web+proto (RFC 9110 sec 8.3), over the shipped HTTP/1.1 server and client.

The module exports one symbol, GrpcWeb. Everything in grpcweb.c has internal linkage.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file grpcweb.h.