Honor advertised WebSocket message size limits (#60841)

## Why

Requests that exceed the server's advertised WebSocket message size limit can fall back to HTTP without first uploading the oversized message.

## What changed

Read `x-codex-websocket-max-message-bytes` from the handshake response and check the serialized request's byte length before sending. Route oversized requests through the existing HTTP fallback. Ignore missing or invalid limits, and remove the close-code-specific wording from the size-limit error.

## Testing

Add a fallback test that advertises a one-byte limit and verifies zero WebSocket generation requests and one HTTP request.

GitOrigin-RevId: 03b42012ca77d6b046e937fef8e6335d855a1c10
This commit is contained in:
Charlie Marsh
2026-11-11 18:58:56 +00:00
committed by copyberry
parent bc3ccba6e1
commit ed7ca22bb6
4 changed files with 34 additions and 6 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ pub enum ApiError {
Api { status: StatusCode, message: String },
#[error("stream error: {0}")]
Stream(String),
#[error("websocket request exceeds the peer's message size limit (close code 1009)")]
#[error("websocket request exceeds the peer's message size limit")]
WebsocketMessageTooLarge,
#[error("stream error: Incomplete response returned, reason: content_filter")]
ContentFilter,