Skip to content

Commit d6bab56

Browse files
authored
docs: fix HTTP gateway streaming callback return type (#296)
## Summary The streaming callback in the HTTP gateway protocol spec must return a non-opt `StreamingCallbackHttpResponse`. The spec incorrectly wrapped the return type in `opt`, which no real gateway accepts — candid cannot coerce wire-type `opt T` into the expected `T`, so serving any multi-chunk (streamed) asset fails to decode. Fixed all three occurrences: - `public/references/http-gateway.did` (downloadable interface) - `docs/references/http-gateway-protocol-spec.md` — full Canister HTTP Interface block - `docs/references/http-gateway-protocol-spec.md` — Response Body Streaming Interface block ```diff - callback: func (StreamingToken) -> (opt StreamingCallbackHttpResponse) query; + callback: func (StreamingToken) -> (StreamingCallbackHttpResponse) query; ``` Note: only the callback's **return type** changes. The `token : opt Token` field inside `StreamingCallbackHttpResponse` stays optional — a null *token* (not a null response) terminates the stream. ## Verification The real gateway decodes the callback reply into a non-opt `StreamingCallbackHttpResponse`: `ic-gateway` → `ic-http-gateway-protocol` (tag `v0.5.1`) → `ic-agent` / `ic-utils` - [`ic-http-gateway-protocol` @ v0.5.1 — `response_handler.rs#L116-L120`](https://github.com/dfinity/ic-http-gateway-protocol/blob/v0.5.1/packages/ic-http-gateway-protocol/src/response/response_handler.rs#L116-L120): calls `http_request_stream_callback` and matches `Ok((StreamingCallbackHttpResponse { body, token },))` — the bare struct, no `Option`. - [`ic-agent` — `ic-utils/src/interfaces/http_request.rs`](https://github.com/dfinity/agent-rs/blob/main/ic-utils/src/interfaces/http_request.rs): `http_request_stream_callback -> SyncCall<Value = (StreamingCallbackHttpResponse,)>`, and the callback CandidType `func((ArgToken) -> (StreamingCallbackHttpResponse) query)`. Detected while adding e2e streaming tests for certified-assets (dfinity/certified-assets#96). `npm run build` passes.
1 parent 6f11614 commit d6bab56

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

docs/references/http-gateway-protocol-spec.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ type StreamingCallbackHttpResponse = record {
423423
424424
type StreamingStrategy = variant {
425425
Callback: record {
426-
callback: func (StreamingToken) -> (opt StreamingCallbackHttpResponse) query;
426+
callback: func (StreamingToken) -> (StreamingCallbackHttpResponse) query;
427427
token: StreamingToken;
428428
};
429429
};
@@ -509,7 +509,7 @@ type StreamingCallbackHttpResponse = record {
509509
510510
type StreamingStrategy = variant {
511511
Callback: record {
512-
callback: func (StreamingToken) -> (opt StreamingCallbackHttpResponse) query;
512+
callback: func (StreamingToken) -> (StreamingCallbackHttpResponse) query;
513513
token: StreamingToken;
514514
};
515515
};

public/references/http-gateway.did

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type StreamingCallbackHttpResponse = record {
3838

3939
type StreamingStrategy = variant {
4040
Callback: record {
41-
callback: func (StreamingToken) -> (opt StreamingCallbackHttpResponse) query;
41+
callback: func (StreamingToken) -> (StreamingCallbackHttpResponse) query;
4242
token: StreamingToken;
4343
};
4444
};

0 commit comments

Comments
 (0)