Commit 0b9a431
committed
feat(client): send a same-origin Origin header by default (streamable HTTP)
The streamable HTTP client sends no Origin header. Browsers always send one
on cross-origin-capable requests; emitting a correct same-origin value matches
that behavior and satisfies servers that gate state-changing requests on a
present, same-origin Origin (defense-in-depth against DNS-rebinding / CSRF),
without weakening any server's posture.
The value is derived from httpx.URL so it uses the exact scheme/host/port
normalization httpx applies to the Host header (default ports dropped, IPv6
hosts bracketed, userinfo stripped). Origin and Host therefore stay
byte-for-byte consistent even for inputs like https://host:443/mcp, where
naive string parsing keeps a redundant :443 that would not match the Host
httpx sends. A caller-provided Origin always wins, and the caller's httpx
client headers are never mutated.
Refs #27271 parent 4472428 commit 0b9a431
2 files changed
Lines changed: 96 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
| |||
88 | 109 | | |
89 | 110 | | |
90 | 111 | | |
91 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
92 | 115 | | |
93 | 116 | | |
94 | 117 | | |
95 | 118 | | |
| 119 | + | |
| 120 | + | |
96 | 121 | | |
97 | 122 | | |
98 | 123 | | |
99 | 124 | | |
100 | 125 | | |
101 | 126 | | |
| 127 | + | |
102 | 128 | | |
103 | 129 | | |
104 | 130 | | |
| |||
134 | 160 | | |
135 | 161 | | |
136 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
137 | 166 | | |
138 | 167 | | |
139 | 168 | | |
| |||
597 | 626 | | |
598 | 627 | | |
599 | 628 | | |
600 | | - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
601 | 633 | | |
602 | 634 | | |
603 | 635 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
364 | 365 | | |
365 | 366 | | |
366 | 367 | | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
367 | 427 | | |
368 | 428 | | |
369 | 429 | | |
| |||
0 commit comments