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

http-proxy does not support the Expected header: 100-continue #1219

Open
damianchojna opened this issue Nov 27, 2017 · 5 comments
Open

http-proxy does not support the Expected header: 100-continue #1219

damianchojna opened this issue Nov 27, 2017 · 5 comments

Comments

@damianchojna
Copy link

If I use http-proxy only as requester, there is a problem with 100-continue.
When we have a response from server with status 100 the requester in http-proxy (proxyReq in web-incoming) do not handle event "continue" and "socket hang up"

@thorntonrp
Copy link

The "proxyReq" callback is invoked too late to apply additional headers.

@thorntonrp
Copy link

thorntonrp commented Jul 28, 2018

Would it be possible to set request headers after the proxyReq event callback? Or perhaps detect whether Expect: 100-continue is included in the request headers and delay forwarding that header until after the proxyReq event callback has been processed?

@thorntonrp
Copy link

thorntonrp commented Jul 28, 2018

As a workaround, I currently set all my headers on the incoming request object inside the HTTP server's "request" event callback. That way they get copied onto the outgoing proxied request before the Expect: 100-continue header is processed for the outgoing request.

@skleeschulte
Copy link

This is my workaround, maybe it helps someone:

const proxy = httpProxy.createProxyServer({
    // ...
});

proxy.before('web', 'stream', (req, res, options) => {
    if (req.headers.expect) {
        req.__expectHeader = req.headers.expect;
        delete req.headers.expect;
    }
});

proxy.on('proxyReq', (proxyReq, req, res, options) => {
    // edit proxy request headers with proxyReq.setHeader(...) and proxyReq.removeHeader(...)

    if (req.__expectHeader) {
        proxyReq.setHeader('Expect', req.__expectHeader);
    }
});

proxy.listen(3000);

@tagkiller
Copy link

Anything new on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants