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
application/x-www-form-urlencoded - for querystring
application/json - for json
- default - to do nothing
In getBodyContent function can be found the snippet
I think this snippet can be improved by parsing the bodyStr in dependence of http header
content-type. For exampleapplication/x-www-form-urlencoded- for querystringapplication/json- for json