Commit 080098e
committed
Client: handle server responses with Content-Length: 0
- When the client sends `notification/initalized`, servers must respond
with HTTP 202 and an empty body. We checked for the absence of a
Content-Type header to verify whether the body was empty.
- However, some servers will send an empty body with a Content-Type
header, and that header may have an unsupported, default type such as
`text/html` or `text/plain`.
- Now we we also use the Content-Length header to check for an empty
body. This header is optional in HTTP/2, so we do not make it our
primary mechanism for detecting empty bodies.
- As part of this PR, we also move hard-coded HTTP header names to the
HttpHeaders interface. While they are not defined by the MCP spec,
they are used by it and are core to implementing the protocol.
Therefore, they have their place in a core interface.
- Fixes #582
Signed-off-by: Daniel Garnier-Moiroux <git@garnier.wf>1 parent 12292ab commit 080098e
File tree
4 files changed
+48
-17
lines changed- mcp-core/src/main/java/io/modelcontextprotocol
- client/transport
- spec
- mcp-spring/mcp-spring-webflux/src/main/java/io/modelcontextprotocol/client/transport
4 files changed
+48
-17
lines changedLines changed: 5 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 21 | + | |
25 | 22 | | |
26 | 23 | | |
27 | | - | |
28 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
469 | 468 | | |
470 | 469 | | |
471 | 470 | | |
472 | | - | |
| 471 | + | |
473 | 472 | | |
474 | 473 | | |
475 | 474 | | |
| |||
Lines changed: 14 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
250 | 250 | | |
251 | 251 | | |
252 | 252 | | |
| |||
371 | 371 | | |
372 | 372 | | |
373 | 373 | | |
374 | | - | |
| 374 | + | |
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
| |||
420 | 420 | | |
421 | 421 | | |
422 | 422 | | |
423 | | - | |
424 | | - | |
425 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
| 462 | + | |
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
467 | | - | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
468 | 473 | | |
469 | | - | |
470 | | - | |
| 474 | + | |
471 | 475 | | |
472 | 476 | | |
473 | 477 | | |
| |||
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
29 | 56 | | |
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
296 | 297 | | |
297 | 298 | | |
298 | | - | |
| 299 | + | |
299 | 300 | | |
300 | 301 | | |
301 | 302 | | |
| |||
0 commit comments