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

body parser doesn't treat content types as case-insensitive #877

Closed
robertklep opened this issue Aug 13, 2015 · 4 comments
Closed

body parser doesn't treat content types as case-insensitive #877

robertklep opened this issue Aug 13, 2015 · 4 comments

Comments

@robertklep
Copy link

Example server:

var restify = require('restify');
var server  = restify.createServer();

server.post('/', restify.jsonBodyParser(), function(req, res, next) {
  console.log('Body:', req.body);
  res.send(200);
  next();
});

server.listen(8080);

When called as follows, req.body unexpectedly is a Buffer:

$ curl -XPOST localhost:8080 -d '{"foo":"bar"}' -H'Content-Type:Application/Json'

(notice the content type case)

It works as expected with this:

$ curl -XPOST localhost:8080 -d '{"foo":"bar"}' -H'Content-Type:application/json'

According to RFC2045: "Matching of media type and subtype is ALWAYS case-insensitive".

@yunong
Copy link
Member

yunong commented Aug 13, 2015

Thanks for finding this bug. Do you have the cycles to send a PR?

@yunong
Copy link
Member

yunong commented Aug 14, 2015

Fixed.

@yunong yunong closed this as completed Aug 14, 2015
@yunong
Copy link
Member

yunong commented Aug 14, 2015

fixed as part of 395c042

@robertklep
Copy link
Author

👍 great work guys!

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 a pull request may close this issue.

2 participants