fix(client): preserve custom Accept headers in StreamableHTTPClientTransport (#1655)
Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com> Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
This commit is contained in:
parent
866c08d364
commit
1eb31236e7
1 changed files with 106 additions and 2 deletions
|
|
@ -237,7 +237,9 @@ export class StreamableHTTPClientTransport implements Transport {
|
|||
// Try to open an initial SSE stream with GET to listen for server messages
|
||||
// This is optional according to the spec - server may not support it
|
||||
const headers = await this._commonHeaders();
|
||||
headers.set('Accept', 'text/event-stream');
|
||||
const userAccept = headers.get('accept');
|
||||
const types = [...(userAccept?.split(',').map(s => s.trim().toLowerCase()) ?? []), 'text/event-stream'];
|
||||
headers.set('accept', [...new Set(types)].join(', '));
|
||||
|
||||
// Include Last-Event-ID header for resumable streams if provided
|
||||
if (resumptionToken) {
|
||||
|
|
@ -538,7 +540,9 @@ export class StreamableHTTPClientTransport implements Transport {
|
|||
|
||||
const headers = await this._commonHeaders();
|
||||
headers.set('content-type', 'application/json');
|
||||
headers.set('accept', 'application/json, text/event-stream');
|
||||
const userAccept = headers.get('accept');
|
||||
const types = [...(userAccept?.split(',').map(s => s.trim().toLowerCase()) ?? []), 'application/json', 'text/event-stream'];
|
||||
headers.set('accept', [...new Set(types)].join(', '));
|
||||
|
||||
const init = {
|
||||
...this._requestInit,
|
||||
|
|
|
|||
Loading…
Reference in a new issue