Commit d9d65b1
fix(streamable-http): return spec-mandated 405 for pre-session GET
A GET the Streamable HTTP server will not serve as a standalone SSE stream
must be answered with 405 Method Not Allowed per the transport spec:
"The server MUST either return Content-Type: text/event-stream in response
to this HTTP GET, or else return HTTP 405 Method Not Allowed, indicating
that the server does not offer an SSE stream at this endpoint."
In stateful mode a session-less GET previously fell through to session
validation and returned 400 "Missing session ID". Spec-compliant clients
(e.g. the TypeScript SDK's _startOrAuthSse) probe with a pre-initialize GET
and treat only 405 as the graceful "no SSE, fall through to POST" signal, so
the 400 made that probe impossible to satisfy and aborted the handshake
before initialize.
Return 405 with `Allow: POST` for a session-less GET that accepts SSE, before
session validation. Legitimate clients only GET after initialize (with a
session id) and are unaffected. Adds a regression test and updates the
security test whose post-Host-check assertion exercised the old 400 path.
Closes #3102
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent e464f72 commit d9d65b1
3 files changed
Lines changed: 44 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
675 | 695 | | |
676 | 696 | | |
677 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
129 | 130 | | |
130 | | - | |
| 131 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
854 | 854 | | |
855 | 855 | | |
856 | 856 | | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
857 | 877 | | |
858 | 878 | | |
859 | 879 | | |
| |||
0 commit comments