Skip to content

gRPC-web v3.17.0

gRPC-web is a browser-compatible protocol that brings gRPC to web applications. GripMock supports gRPC-web unary and streaming calls, with the same stubs and features as ConnectRPC and native gRPC.

The gateway serves gRPC-web and ConnectRPC on a single port (:4769 by default). Content-Type negotiation dispatches to the correct handler automatically. See ConnectRPC for the companion protocol.

HTTP Interface

POST /{service}/{method}

Content Types

Content-TypeFormat
application/grpc-web+jsonJSON (length-prefixed + trailers)
application/grpc-web+protoProtobuf binary (length-prefixed + trailers)

Wire Format

All messages are length-prefixed using a 5-byte envelope:

[1 byte flags][4 byte length (BE u32)][payload bytes]
FlagMeaning
0x00Uncompressed data frame
0x01Compressed data frame (not supported; use Content-Encoding: gzip)
0x80Trailers frame (final frame with grpc-status / grpc-message)

Unary

Response consists of a data frame followed by a trailers frame. HTTP status is always 200 OK; the actual gRPC status is carried in the trailers:

http
HTTP/1.1 200 OK
Content-Type: application/grpc-web+proto

[0x00][4-byte len][proto message]
[0x80][4-byte len][grpc-status: 0\r\n]

Errors

Errors are communicated via trailers in a trailers-only response:

http
HTTP/1.1 200 OK
Content-Type: application/grpc-web+proto

[0x80][4-byte len][grpc-status: 5\r\ngrpc-message: not found\r\n]

Streaming

Same envelope framing. Multiple data frames followed by a final trailers frame.

Request Headers

HeaderDescription
Content-Typeapplication/grpc-web+json or application/grpc-web+proto
Content-Encodinggzip, deflate, zstd, snappy, or br
Accept-Encodinggzip or deflate (response compression)
X-Gripmock-SessionSession ID for call tracking

Examples

JSON (unary)

bash
curl -X POST http://localhost:4769/test.TestService/TestMethod \
  -H "Content-Type: application/grpc-web+json" \
  -d '{"name":"Alice"}'

Proto Binary (unary)

bash
curl -X POST http://localhost:4769/test.TestService/TestMethod \
  -H "Content-Type: application/grpc-web+proto" \
  --data-binary @request.pb

Unsupported: text encoding

application/grpc-web-text+* (base64) is not supported. Use application/grpc-web+proto or application/grpc-web+json instead.

Stub Configuration

Stubs work identically across all protocols. See ConnectRPC for examples.

Features

All features from ConnectRPC apply to gRPC-web as well — input matching, templates, delays, errors, headers, streaming, compression, and OpenTelemetry.

The key difference: gRPC-web always uses HTTP 200 OK (actual status in trailers), while ConnectRPC returns non-200 HTTP codes for errors.

TLS

Configured via GATEWAY_TLS_* variables. See Environment Variables.

Comparison

FeaturegRPC-webConnectRPCgRPC
Browser supportDirectDirectRequires proxy
Unary response formatLength-prefixed + trailersRaw bodyLength-prefixed
HTTP status on errorAlways 200Non-200Always 200
Error locationTrailers frameJSON bodyTrailers
JSON supportNativeNativeVia codec
StreamingFull (envelope)Full (envelope)Full