Skip to content

Commit 94763b2

Browse files
sharpninjaCopilot
andcommitted
fix(voice): SSE streaming Accept header for proxy compatibility
- Client sends Accept: text/event-stream instead of application/json - Prevents ngrok/reverse proxy buffering of SSE responses - Server adds X-Accel-Buffering: no header (submodule b9c8dc6) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5162f08 commit 94763b2

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/McpServerManager.Core/Services/McpVoiceConversationService.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,16 @@ public async IAsyncEnumerable<McpVoiceTurnStreamEvent> SubmitTurnStreamingAsync(
110110
var jsonBody = JsonSerializer.Serialize(request, JsonOptions);
111111
using var content = new StringContent(jsonBody, System.Text.Encoding.UTF8, "application/json");
112112

113-
// ResponseHeadersRead is critical: starts returning stream data immediately
114-
// instead of buffering the entire response
113+
var httpRequest = new HttpRequestMessage(HttpMethod.Post,
114+
$"mcp/voice/session/{Uri.EscapeDataString(sessionId)}/turn/stream")
115+
{ Content = content };
116+
// SSE requires text/event-stream Accept header for proper proxy behavior
117+
httpRequest.Headers.Accept.Clear();
118+
httpRequest.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("text/event-stream"));
119+
120+
// ResponseHeadersRead starts returning stream data immediately
115121
response = await client.SendAsync(
116-
new HttpRequestMessage(HttpMethod.Post,
117-
$"mcp/voice/session/{Uri.EscapeDataString(sessionId)}/turn/stream")
118-
{ Content = content },
122+
httpRequest,
119123
HttpCompletionOption.ResponseHeadersRead,
120124
cancellationToken).ConfigureAwait(false);
121125
await EnsureSuccessAsync(response, cancellationToken).ConfigureAwait(false);

0 commit comments

Comments
 (0)