question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Empty body on HTTP error response

See original GitHub issue

I had a problem where the response body would come up empty, when the server responded with 401:

2015-08-31 17:11:01.168 [MyInterface#myMethod] <--- HTTP/1.1 401 Unauthorized (12ms)
2015-08-31 17:11:01.169 [MyInterface#myMethod] Date: Mon, 31 Aug 2015 15:11:01 GMT
2015-08-31 17:11:01.169  [MyInterface#myMethod] Content-Length: 71
2015-08-31 17:11:01.170  [MyInterface#myMethod] Content-Type: application/json
2015-08-31 17:11:01.170  [MyInterface#myMethod] <--- END HTTP (0-byte body)

As indicated by content-length header, the body should be 71 bytes, and it is (verified with tcpdump). The empty body caused a NPE when the ErrorDecoder had nothing to decode and returned null, which SynchronousMethodHandler then tried to throw (line 121).

During previous testing, with 200 OK it worked fine, if I recall correct.

This was with the Default client. Using OkHttpClient instead, the issue disappeared.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
rage-shadowmancommented, Dec 6, 2018

@344310362 english comments are more likely to be understood by most of the people following this project.

Google translate isn’t very good here as it turns that into:

When this fix is released, how can I set the parameters to death?

Perhaps a better translation of “death” would be “null”?

0reactions
minhnguyenvan95commented, Oct 12, 2022

Did anybody had a workaround to resolve this issue? It is existing I am using JDK 11 and Openfeign 2.2.6. I have tried with other clients other than the default Okhttp and Apache HttpClient and still getting empty response body with 401 error response.

Same too me , response code = 401 the response body return null, JDK 17, Feign 3.1.4

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the proper REST response code for a valid request but ...
200 Ok should be used when the user gets the resource. Empty is not a resource. 400 range is for client errors 500...
Read more >
Should an HTTP API always return a body?
The use case is that the client is expecting valid JSON, even if the response is "empty" or has no content. A good...
Read more >
Empty or incomplete HTTPS response body in HTTP client
Sometimes the HTTP Body in an HTTPS response is incomplete when using the OpenEdge HTTP client. Sometimes the last part of an HTTP...
Read more >
How can I capture an empty response error, which for my use ...
I make a valid web services call. The expected response has an empty body, but what I need are the headers that are...
Read more >
When HttpResponse body is empty it returns a ValueError ...
In checkin 7b846ea the code for httpclient.HttpResponse.body was changed to throw a ValueError when the body is empty. But since the message ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found