Commit 79cea44
fix: Allow POST requests without Content-Type header when body is empty (#759)
Per RFC 9110 §8.3, Content-Type header is only meaningful when a message
body is present. The HTTP+JSON transport was incorrectly returning 415
(ContentTypeNotSupportedError) for POST requests with no body and no
Content-Type header.
This fix adds validateContentTypeForOptionalBody() method to handle
endpoints like POST /tasks/{id}:cancel where the body is optional. When
the body is null or empty, Content-Type validation is skipped. When body
content is present, Content-Type must still be application/json.
This allows bodyless POST requests to be processed correctly and return
appropriate errors (404 TaskNotFoundError, 409 TaskNotCancelableError)
instead of 415.
Fixes #747 🦕
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent c14ec7f commit 79cea44
File tree
1 file changed
+20
-1
lines changed- reference/rest/src/main/java/io/a2a/server/rest/quarkus
1 file changed
+20
-1
lines changedLines changed: 20 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
346 | 346 | | |
347 | 347 | | |
348 | 348 | | |
349 | | - | |
| 349 | + | |
350 | 350 | | |
351 | 351 | | |
352 | 352 | | |
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
627 | 646 | | |
628 | 647 | | |
629 | 648 | | |
| |||
0 commit comments