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

defaultRequestParser.getBodyContent #27

Open
smart--petea opened this issue Sep 25, 2014 · 1 comment
Open

defaultRequestParser.getBodyContent #27

smart--petea opened this issue Sep 25, 2014 · 1 comment
Assignees
Milestone

Comments

@smart--petea
Copy link
Contributor

In getBodyContent function can be found the snippet

       req.on('end', function() {
            if(bodyStr.match(/^\S+=\S+&?/)) {
                cb(qs.parse(bodyStr));
            } else {
                try {
                    return cb(JSON.parse(bodyStr))
                } catch (ex) {
                    return cb(bodyStr);
                }
            }
        });

I think this snippet can be improved by parsing the bodyStr in dependence of http header content-type. For example

  1. application/x-www-form-urlencoded - for querystring
  2. application/json - for json
  3. default - to do nothing
@deleteman deleteman self-assigned this Sep 25, 2014
@deleteman
Copy link
Owner

I like this, I'll take care of it, thanks for the suggestion!

@deleteman deleteman added this to the Version 1.4 milestone Nov 20, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants