Commit 92a1e3c
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 19fe9fa commit 92a1e3c
2 files changed
Lines changed: 94 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
53 | 74 | | |
54 | 75 | | |
55 | 76 | | |
| |||
72 | 93 | | |
73 | 94 | | |
74 | 95 | | |
75 | | - | |
| 96 | + | |
76 | 97 | | |
77 | 98 | | |
78 | 99 | | |
79 | 100 | | |
| 101 | + | |
| 102 | + | |
80 | 103 | | |
81 | 104 | | |
| 105 | + | |
82 | 106 | | |
83 | 107 | | |
84 | 108 | | |
| |||
92 | 116 | | |
93 | 117 | | |
94 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
95 | 122 | | |
96 | 123 | | |
97 | 124 | | |
| |||
547 | 574 | | |
548 | 575 | | |
549 | 576 | | |
550 | | - | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
551 | 581 | | |
552 | 582 | | |
553 | 583 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | | - | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
355 | 356 | | |
356 | 357 | | |
357 | 358 | | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 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 | + | |
358 | 418 | | |
359 | 419 | | |
360 | 420 | | |
| |||
0 commit comments