{{ message }}
Repository navigation
Commit f8f1f92
committed
Avoid default Content-Type on POST/PUT/PATCH with empty body
DefaultClient wrote a zero-length byte array to the connection's
output stream whenever the HTTP method was not GET, even when the
request body was empty. Opening that output stream makes
HttpURLConnection create an internal "poster" and, as soon as one
exists, the JDK defaults Content-Type to
application/x-www-form-urlencoded if none was set - even though no
bytes are actually written.
This regressed in 12.0 (feign#1778, fixing the Content-Length: 0
case) and silently adds an incorrect Content-Type header, which can
cause servers to reject the request with 415 Unsupported Media Type.
Skip the output stream entirely for empty/absent bodies and set
Content-Length: 0 directly, matching the existing null-body path.
Fixes #2068
Signed-off-by: seonwoo_jung <79202163+seonwooj0810@users.noreply.github.com>1 parent 661b398 commit f8f1f92
3 files changed
Lines changed: 32 additions & 9 deletions
File tree
- core/src
- main/java/feign
- test/java/feign/client
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
232 | 242 | | |
233 | 243 | | |
234 | 244 | | |
| |||
612 | 622 | | |
613 | 623 | | |
614 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
615 | 628 | | |
616 | 629 | | |
617 | 630 | | |
| |||

0 commit comments