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

Form content-type lost the charset somewhere >2.40.0 #1644

Closed
jkrems opened this issue Jun 16, 2015 · 6 comments
Closed

Form content-type lost the charset somewhere >2.40.0 #1644

jkrems opened this issue Jun 16, 2015 · 6 comments

Comments

@jkrems
Copy link

jkrems commented Jun 16, 2015

Headers using request@2.40.0:

{ 'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
  'content-length': '14' }

Headers using request@2.57.0:

{ 'content-type': 'application/x-www-form-urlencoded',
  'content-length': '14' }

This causes problems with services that default to a different charset.

@jkrems
Copy link
Author

jkrems commented Jun 16, 2015

Guess this was caused by #1159. Confused why some stacks are apparently not affected by this since it does look like the form parameters are encoded as utf-8. So a decoder on the other side trying to read it as something else should break afaict.

@jkrems
Copy link
Author

jkrems commented Jun 16, 2015

Would it be acceptable to have an option (e.g. forceFormEncoding: true) to restore the old behavior? Or at least honor existing content-type headers in req.form(x)? If so, I'd be happy to create a PR. :)

@simov
Copy link
Member

simov commented Jun 17, 2015

Request should honor any user defined header. According to this #701 (comment) it seems that this was working back then, but I just tested and it's not, so probably something changed along the way. I'm going to investigate that. As for forceFormEncoding option, I don't think that would be necessary if the content-header can be overriden by the user (like it should).

@jkrems
Copy link
Author

jkrems commented Jun 17, 2015

Sounds good! For clarity: We are currently using a delayed setHeader in gofer to restore the old behavior. But it would be great if options.headers['content-type'] would work as well (since the current workaround code looks pretty ugly).

@simov
Copy link
Member

simov commented Jun 21, 2015

@jkrems just pushed the fix #1650 also I just noticed that the example here #701 (comment) is using body instead of form.

@jkrems
Copy link
Author

jkrems commented Jun 21, 2015

@simov Thanks for the update! :)

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

No branches or pull requests

2 participants