-
Notifications
You must be signed in to change notification settings - Fork 594
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
Unirest 4.x - Duplicate content-type header is being added for request #486
Comments
The additional header is being added from here https://github.com/Kong/unirest-java/blob/main/unirest/src/main/java/kong/unirest/core/java/BodyBuilder.java#L73 |
Its only duplicate because you added it twice. Don't do that. |
Sorry am I missing something, where am I adding it twice? Are you saying, I shouldn't be adding it at all? |
Ah I see you've added a check. Thanks. |
Unirest has always automatically added the header, in the old 3 line there was a check that didn't auto-add it if it existed, so I pulled that into 4, but Unirest will still let you add multiple headers of the same type IF you want. The HTTP spec says you "shouldn't" do this and then points out exceptions to the rule, so from a tool standpoint, Unirest will let you do it. Your code in the example really shouldn't add the header and let unirest just add it automatically. |
fixed in 4.0.4 |
Thanks a lot for adding the check. It took me some good time to work out why it was failing. We use an interceptor to log the request and responses but it looks like the interceptor on
|
Describe the bug
Duplicate content-type is being added for a request with content-type header and body fields
To Reproduce
Steps to reproduce the behavior:
content-type=application/x-www-form-urlencoded
set with body fieldsExpected behavior
A single content-type header is sent
Screenshots
If applicable, add screenshots to help explain your problem.
Environmental Data:
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: