Commit 3fecf35
authored
feat: accept empty content body in HttpJsonTranscodingService (#6325)
Motivation
HttpJsonTranscodingService currently fails with 400 Bad Request when handling a request with Content-Type: application/json and no body, even if the corresponding google.api.http rule uses body: "*". This behavior is inconsistent with common implementations such as Envoy and grpc-gateway, which treat empty bodies as {} in such cases.
⸻
Modifications
- **HttpJsonTranscodingService**
- Added a fallback to use an empty JSON object when body empty ( content-length: 0 )
- Treat **empty request bodies** as `{}` when **all** of the following are true:
- **Content-Type**: `application/json`
- **google.api.http rule**: `body: "*"`
⸻
Result
- Closes #6319.
- Users can now send requests with Content-Type: application/json and an empty body without receiving a 400 Bad Request error.
- Ensures better compatibility with gRPC transcoding conventions from other ecosystems1 parent ae45261 commit 3fecf35
2 files changed
Lines changed: 32 additions & 12 deletions
File tree
- grpc/src
- main/java/com/linecorp/armeria/server/grpc
- test/java/com/linecorp/armeria/it/grpc
Lines changed: 18 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
745 | | - | |
746 | | - | |
747 | | - | |
748 | | - | |
749 | | - | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
750 | 758 | | |
751 | | - | |
752 | 759 | | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
757 | 763 | | |
| 764 | + | |
| 765 | + | |
758 | 766 | | |
759 | 767 | | |
760 | 768 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
920 | | - | |
| 920 | + | |
921 | 921 | | |
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
926 | 926 | | |
927 | 927 | | |
928 | | - | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
929 | 941 | | |
930 | 942 | | |
931 | 943 | | |
| |||
0 commit comments