Skip to content
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

HEAD requests content-length is not based on the body as per the http… #896

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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

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!

… 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.

4 participants