Skip to content

Conversation

@nizarm
Copy link
Contributor

@nizarm nizarm commented Apr 20, 2023

HEAD requests content-length is not based on the body as per the http spec. Fixing it to not override the content-length if the request is HEADER type

@nizarm nizarm requested review from bohhyang and gu0keno0 April 20, 2023 00:04
Comment on lines 93 to 96
boolean addContentLengthHeader = true;
if ("HEAD".equalsIgnoreCase(request.getMethod())) {
addContentLengthHeader = false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there a way to get this as an enum? Feels like a string equality check is a little weak... Otherwise, this feels better anyway:

boolean addContentLengthHeader = !"HEAD".equalsIgnoreCase(request.getMethod());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree enum is more cleaner way to do the check, but its not available in the repo without introducing additional dependencies.

Simplified the conditional statement as per the comment

Copy link

@yzhan1 yzhan1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

nizarm added 4 commits April 20, 2023 14:56
… spec. Fixing it to not override the content-length if the request is HEADER type
… spec. Fixing it to not override the content-length if the request is HEADER type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants