Commit f53bafa
authored
feat(server): describe batch binary responses with a dedicated content type (#1761)
Batch responses that use the length-prefixed binary framing — streaming
mode, and buffered mode when a sub-response carries binary — now
advertise `application/vnd.orpc.batch` instead of falling back to
`application/octet-stream`. Batch traffic is now distinguishable from
ordinary file transfers in proxy logs, CDN rules, and dev tools, where
before it was indistinguishable from any other opaque byte stream.
`application/octet-stream` means "unknown bytes" and was never chosen
for batch — it is what the adapter fills in for any `ReadableStream`
body with no content type set. The framing is a format oRPC defines, so
it gets a name.
## Compatibility
Nothing changes on the wire. Clients resolve the batch body from the
`standard-server` hint (`octet-stream` / `file`), not from
`content-type`, so old clients read new servers and new clients read old
servers. Compression behavior is also unchanged: the new type sits
outside the compressible allow-list, exactly like the old one, so batch
bodies are still passed through untouched.
A `+json` suffix was considered and rejected — it would assert the whole
body is JSON (it is binary length prefixes wrapping JSON, sometimes with
raw binary appended), and it would pull streaming batches into
`CompressionStream`, which does not sync-flush per chunk and would hold
frames back instead of delivering them as each sub-request completes.
The all-JSON buffered path is untouched and still serializes as
`application/json`. In streaming mode the plugin's content type wins
over the `headers` option, matching buffered mode, which already
hardcodes the type on the `Blob`.
## Testing
Both framing paths assert the new header. Full root suite passes (2772
passed, 41 skipped), along with `pnpm type:check` across all packages
and `pnpm lint`.1 parent 4dc0866 commit f53bafa
2 files changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
| |||
212 | 213 | | |
213 | 214 | | |
214 | 215 | | |
| 216 | + | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
11 | 20 | | |
12 | 21 | | |
13 | 22 | | |
| |||
216 | 225 | | |
217 | 226 | | |
218 | 227 | | |
219 | | - | |
| 228 | + | |
220 | 229 | | |
221 | 230 | | |
222 | 231 | | |
| |||
294 | 303 | | |
295 | 304 | | |
296 | 305 | | |
297 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
298 | 311 | | |
299 | 312 | | |
300 | 313 | | |
| |||
0 commit comments