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

Content-Type lookup is case sensitive #129

Closed
chrisgilmerproj opened this issue Sep 29, 2016 · 2 comments
Closed

Content-Type lookup is case sensitive #129

chrisgilmerproj opened this issue Sep 29, 2016 · 2 comments

Comments

@chrisgilmerproj
Copy link

chrisgilmerproj commented Sep 29, 2016

Using fetch() method from javascript and it does a lowercase operation before it send out my header. That means Content-Type becomes content-type.

This problem was noted in the code already:

https://github.com/awslabs/chalice/blob/master/chalice/app.py#L72-L75

Turns out this problem happened recently with the addition of 1a2ae87.

I suggest just checking for both:

if self.headers.get('Content-Type') == 'application/json' or \
        self.headers.get('content-type') == 'application/json' :
    self.json_body = body

Headers should be case-insensitive, so perhaps the class should lowercase all the headers as it reads them?

hadrien added a commit to hadrien/chalice that referenced this issue Sep 30, 2016
hadrien added a commit to hadrien/chalice that referenced this issue Sep 30, 2016
hadrien added a commit to hadrien/chalice that referenced this issue Sep 30, 2016
Lowercase all header keys at request init.
jamesls pushed a commit that referenced this issue Oct 10, 2016
Lowercase all header keys at request init.
jamesls added a commit that referenced this issue Oct 10, 2016
* hadrien-fix/129-content-type-lookup-is-case-sensitive:
  Ensure to_dict() is JSON serializable
  Update changelog with latest changes
  Read-only case insensitive mapping for headers.
  Fix issue #129
@jamesls
Copy link
Member

jamesls commented Oct 10, 2016

Closing, #130 has been merged.

@jamesls jamesls closed this as completed Oct 10, 2016
@chrisgilmerproj
Copy link
Author

Thanks so much for the work on this!

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