-
Notifications
You must be signed in to change notification settings - Fork 913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relax validation for responses with empty content status. #5862
Conversation
Motivation: An exception is currently raised when aggregating a response if the response's status indicates empty content but content is present. However, a third-party legacy server might send a response with content despite an empty content status, which is beyond the client's control. Modification: - Changed the behavior to log a debug message instead of raising an exception when content exists for a status that indicates empty content. Result: - Armeria client now works with legacy servers that send content with an empty content status without raising exceptions.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5862 +/- ##
============================================
+ Coverage 74.57% 74.61% +0.04%
- Complexity 21643 21693 +50
============================================
Files 1893 1896 +3
Lines 80153 80383 +230
Branches 10523 10575 +52
============================================
+ Hits 59772 59980 +208
- Misses 15341 15344 +3
- Partials 5040 5059 +19 ☔ View full report in Codecov by Sentry. |
if (!tryWrite(headers)) { | ||
return; | ||
} | ||
|
||
// Add content if not empty. | ||
if (!contentAlwaysEmpty && !content.isEmpty()) { | ||
if (headers.status().isContentAlwaysEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to release the resource?
if (headers.status().isContentAlwaysEmpty()) { | |
if (headers.status().isContentAlwaysEmpty()) { | |
content.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
if (!tryWrite(headers)) { | ||
return; | ||
} | ||
|
||
// Add content if not empty. | ||
if (!contentAlwaysEmpty && !content.isEmpty()) { | ||
if (headers.status().isContentAlwaysEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍 👍
import com.linecorp.armeria.common.util.Exceptions; | ||
|
||
final class HttpResponseUtil { | ||
|
||
static final Logger logger = LoggerFactory.getLogger(HttpResponseUtil.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional) HttpResponseUtil
seems like an package-private class which makes it susceptible to us refactoring this class without realizing that users are using this logger pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment for that. 😉
Motivation:
An exception is currently raised when aggregating a response if the response's status indicates empty content but content is present. However, a third-party legacy server might send a response with content despite an empty content status, which is beyond the client's control.
Modification:
Result: