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

Not able to set Content-Type with UTF-8 in header #144

Open
Nordes opened this issue Dec 11, 2017 · 2 comments
Open

Not able to set Content-Type with UTF-8 in header #144

Nordes opened this issue Dec 11, 2017 · 2 comments
Labels

Comments

@Nordes
Copy link

Nordes commented Dec 11, 2017

Hi, maybe I am doing it wrong, but I am not able to set the CharSet in the headers.

(Needed to send some japanese body)
Usually in postman: Content-Type: application/json; charset=UTF-8

I`ve tried to set the headers :

{ 'Content-Type': 'application/json; charset=UTF-8' }

But it fails. It still send the wrong text.

@Nordes
Copy link
Author

Nordes commented Dec 11, 2017

I was actually able to set it like the following:

  1. Create the client (with options...)
  2. myClient.headers["content-type"] = 'application/json; charset=UTF-8'

I previously tried using the creation options contentType but it didn't change anything. Was it a wanted behavior?

@DonutEspresso
Copy link
Member

Hi @Nordes , you can set headers using the options 'headers':

client.post({ 
  headers: { 
    'content-type': 'foobarbaz' 
  }, 
  path: '/' 
}, function() { ... });

That said, for content-type specifically, we seem to be deleting content-type headers for GET/HEAD/DELETE verbs. While generally this seems reasonable, in reading the RFC it doesn't actually suggest that content-type is required (or disallowed) based on the verbs. This seems like a legitimate bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants