Fix SSE content-type error message format

This commit is contained in:
David Dworken 2025-05-29 14:01:36 -07:00
commit 970905c313
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -264,7 +264,7 @@ describe('SSEServerTransport', () => {
await transport.handlePostMessage(mockReq, mockHandleRes, { jsonrpc: '2.0', method: 'test' });
expect(mockHandleRes.writeHead).toHaveBeenCalledWith(400);
expect(mockHandleRes.end).toHaveBeenCalledWith('Error: Content-Type must start with application/json, got: text/plain');
expect(mockHandleRes.end).toHaveBeenCalledWith('Error: Unsupported content-type: text/plain');
});
});

View file

@ -155,7 +155,7 @@ export class SSEServerTransport implements Transport {
try {
const ct = contentType.parse(req.headers["content-type"] ?? "");
if (ct.type !== "application/json") {
throw new Error(`Unsupported content-type: ${ct}`);
throw new Error(`Unsupported content-type: ${ct.type}`);
}
body = parsedBody ?? await getRawBody(req, {