express-http-proxy
express-http-proxy copied to clipboard
form-urlencoded requests do not proxy correctly if content-type contains a semi-colon
If the content-type header of the request is like "application/x-www-form-urlencoded; charset=UTF-8" the following logic is not functioning properly in the sendProxyRequest.js:
if (bodyContent.length) {
var body = bodyContent;
var contentType = proxyReq.getHeader('Content-Type');
if (contentType === 'x-www-form-urlencoded' || contentType === 'application/x-www-form-urlencoded') {
try {
var params = JSON.parse(body);
body = Object.keys(params).map(function(k) { return k + '=' + params[k]; }).join('&');
} catch (e) {
// bodyContent is not json-format
}
}
What ends up happening is the bodyContent is a JSON and it gets sent improperly.
The body-parser seems to have no issues with this content-type.
The contentType detection of urlencoded should not break if there is a semi-colon followed by the charset or other segments of the contentType.
As a work around - I can add a custom proxyReqOptDecorator and capture the content-type from the caller and "sanitize" the content-type and remove the semi-colon segment as a temporary fix. But I should not need to do that.
I created the following PR with a potential fix: https://github.com/villadora/express-http-proxy/pull/489
I proposed a straight forward issue with a straight forward fix, no comments and no follow-up? Any tips to get something done here?