grantila / fetch-h2

HTTP/1+2 Fetch API client for Node.js
MIT License
336 stars 16 forks source link

"Cannot set forbidden header for requests" on pushed response #66

Closed triblondon closed 4 years ago

triblondon commented 4 years ago

I set up an onPush handler, and am finding that when I trigger a push from my server, nodeJS throws with:

TypeError: Header guard error: Cannot set forbidden header for requests (accept-encoding)
    at _ensureGuard (/node_modules/fetch-h2/dist/lib/headers.js:70:15)
    at GuardedHeaders.set (/node_modules/fetch-h2/dist/lib/headers.js:141:9)
    at set (/node_modules/fetch-h2/dist/lib/headers.js:90:22)
    at new Headers (/node_modules/fetch-h2/dist/lib/headers.js:106:17)
    at new GuardedHeaders (/node_modules/fetch-h2/dist/lib/headers.js:152:9)
    at new Request (/node_modules/fetch-h2/dist/lib/request.js:37:25)
    at H2Context.handlePush (/node_modules/fetch-h2/dist/lib/context-http2.js:176:31)
    at session.on.aGuard (/node_modules/fetch-h2/dist/lib/context-http2.js:232:67)
    at ClientHttp2Session.<anonymous> (/node_modules/callguard/dist/index.js:72:43)
    at ClientHttp2Session.emit (events.js:198:13)
    at emit (internal/http2/core.js:236:8)
    at process._tickCallback (internal/process/next_tick.js:63:19)

The onPush callback never gets called. I guess my server is sending an Accept-Encoding header as part of the PUSH_PROMISE? Seems like fetch should allow this, since I don't have any control over what servers would include in a push.

stefan-guggisberg commented 4 years ago

I face the same problem. Server sends the PUSH_PROMISE which includes an accept-encoding header.

fetch in the browser (chrome) works with the same url.

grantila commented 4 years ago

:tada: This issue has been resolved in version 2.2.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: