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

proxyReq.setHeader in 'proxyReq' event callback throw 'Cannot set headers after they are sent to the client' #1328

Closed
anson0370 opened this issue Mar 13, 2019 · 2 comments

Comments

@anson0370
Copy link

I did some debug and figured out what's happened.
In my case, this is because I was using curl to post a request with a body size bigger than 1024. curl sends a http request with header expect: 100-continue before sends the post request.

Looks like the problem is in Node http module:

    // _http_client.js: 221
    if (this.getHeader('expect')) {
      if (this._header) {
        throw new ERR_HTTP_HEADERS_SENT('render');
      }
      // here set headers for the request, so when we call proxyReq.setHeader later, it throw an exception
      this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n',
                        this[outHeadersKey]);
    }

Maybe we can check is here a expect header before fire proxyReq event, or ignore the setHeader invoke?

@skleeschulte
Copy link

I found a workaround that might also help in your case: #1219 (comment)

@jsmylnycky
Copy link
Contributor

Fixed as part of #1447

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

3 participants