Commit d6bab56
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
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
512 | | - | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
0 commit comments