Skip to content

defaultRequestParser.getBodyContent #27

@smart--petea

Description

@smart--petea

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

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions