-
Notifications
You must be signed in to change notification settings - Fork 234
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
content-length
request header is removed when parseReqBody
is false
#545
Comments
@mdmower-csnw Thanks for this detailed report. I'll take a look. |
@mdmower-csnw Thanks for the report. I ended up following your parenthetical advice and not removing |
Thanks for the quick attention on this, @monkpow! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
When option
{parseReqBody: false}
is used, the original requestcontent-length
header is lost when the request is forwarded to the target origin.Analysis
It looks like the header is removed here:
express-http-proxy/lib/requestOptions.js
Lines 52 to 65 in b05cb04
But then is only recalculated when
parseReqBody
istrue
, here:express-http-proxy/app/steps/sendProxyRequest.js
Line 57 in b05cb04
Potential solution
When
{parseReqBody: false}
...bodyContent
is provided, thencontent-length
could be determined from the size ofbodyContent
bodyContent
is not provided (i.e.proxyReq
is piped), then the originalcontent-length
header could be restored (if defined)Supposing number item 1 is handled (
content-length
determined from size ofbodyContent
), then it may not be necessary to removecontent-length
from the original request at all. It would be overwritten insendProxyRequest
when appropriate and left alone otherwise.The text was updated successfully, but these errors were encountered: