HTTP Stream RFC
XIDL HTTP Stream Mapping Specification
Section titled “XIDL HTTP Stream Mapping Specification”This page defines a streaming profile built on top of HTTP mapping, used to express long-connection request or response streams.
This RFC mainly defines:
- Streaming method models.
- Annotations and type constraints.
- HTTP wire protocol recommendations.
- Codec selection.
- Lifecycle, cancellation, and error semantics.
This page does not define:
- Message broker transport.
- Reliability semantics beyond HTTP itself.
- Exactly-once delivery.
Streaming Method Annotations
Section titled “Streaming Method Annotations”A method is considered a streaming method if it carries one of the following annotations:
@server_stream@client_stream
Optional annotations:
@path @rename("...")@stream_codec("ndjson" | "sse")- HTTP security-related annotations.
Default values:
- HTTP method:
POST - Codec:
ndjson - Path:
/{method_name}
Type Constraints
Section titled “Type Constraints”@client_streammust have exactly one streaming input parameter of typesequence<T>.- The return value of
@server_streammust besequence<T>. @server_streamand@client_streamare mutually exclusive.
Interaction Model
Section titled “Interaction Model”Server Stream
Section titled “Server Stream”- The client sends a single request object.
- The server continuously returns multiple stream items.
Client Stream
Section titled “Client Stream”- The client continuously sends multiple stream items.
- The server finally returns a single completion result.
Route Templates
Section titled “Route Templates”Streaming methods follow the same path template rules as the standard HTTP RFC:
{name}{*name}{?name1,name2,...}
Query and Path variables are still bound by @query and @path.
Security Model
Section titled “Security Model”Streaming methods reuse the rules from the HTTP Security RFC:
- Interface-level declarations provide defaults.
- Method-level declarations override defaults.
@no_securityclears inherited requirements.
Additional notes for streaming:
- Authentication occurs before the stream is established.
- Credentials are not part of the stream item payload.
- Token refresh and session renewal are implementation concerns.
Wire Profile
Section titled “Wire Profile”General HTTP Requirements
Section titled “General HTTP Requirements”Content-Typemust match the selected codec.- Long-connection responses typically use chunked transfer encoding.
- Proxies or gateways should avoid unnecessary buffering.
NDJSON
Section titled “NDJSON”The default codec is ndjson.
Common MIME type:
application/x-ndjson
Frame object example:
{ "t": "next", "seq": 1, "data": 42 }Common fields:
t: Frame type.seq: Monotonically increasing sequence number for each direction.data: Business data.error: Error information.meta: Additional metadata.
sse is only applicable to @server_stream.
Common mappings:
event: nextevent: errorevent: complete
Lifecycle
Section titled “Lifecycle”Start:
- The stream is considered established only after the server accepts the request and returns a success status.
End:
- Receipt of
complete. - Receipt of
error. - Explicit
cancel. - Transport disconnection.
Byte Stream Modeling
Section titled “Byte Stream Modeling”If you want to express a byte stream, you can model the stream item type as octet:
sequence<octet>represents a sequence of byte items.
The specific on-wire encoding depends on the selected codec.
Implementation Recommendations
Section titled “Implementation Recommendations”- Prioritize robust implementation of
server_stream. - Codec and security rules should remain consistent with standard HTTP mapping.
seqshould be guaranteed to monotonically increase for each direction and stream.