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

properly handle pseudo-headers in fetch #2422

Merged
merged 1 commit into from
Nov 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
properly handle pseudo-headers in fetch
properly handle pseudo-headers in fetch
  • Loading branch information
KhafraDev committed Nov 10, 2023
commit 0dcf87944a714a3ce901c2892460ff48b3656ecf
6 changes: 3 additions & 3 deletions lib/fetch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,7 @@ async function httpNetworkFetch (
location = val
}

headers.append(key, val)
headers[kHeadersList].append(key, val)
}
} else {
const keys = Object.keys(headersList)
Expand All @@ -2016,7 +2016,7 @@ async function httpNetworkFetch (
location = val
}

headers.append(key, val)
headers[kHeadersList].append(key, val)
}
}

Expand Down Expand Up @@ -2120,7 +2120,7 @@ async function httpNetworkFetch (
const key = headersList[n + 0].toString('latin1')
const val = headersList[n + 1].toString('latin1')

headers.append(key, val)
headers[kHeadersList].append(key, val)
}

resolve({
Expand Down
11 changes: 6 additions & 5 deletions test/fetch/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ const { once } = require('node:events')
const { Blob } = require('node:buffer')
const { Readable } = require('node:stream')

const { test, plan, skip } = require('tap')
const { test, plan } = require('tap')
const pem = require('https-pem')

const { Client, fetch } = require('../..')

const nodeVersion = Number(process.version.split('v')[1].split('.')[0])

skip('Skip H2 test due to pseudo-header issue.')
process.exit(0)

plan(6)

test('[Fetch] Issue#2311', async t => {
Expand Down Expand Up @@ -87,7 +84,7 @@ test('[Fetch] Simple GET with h2', async t => {
stream.end(expectedRequestBody)
})

t.plan(4)
t.plan(5)

server.listen()
await once(server, 'listening')
Expand Down Expand Up @@ -120,6 +117,10 @@ test('[Fetch] Simple GET with h2', async t => {
t.equal(responseBody, expectedRequestBody)
t.equal(response.headers.get('x-method'), 'GET')
t.equal(response.headers.get('x-custom-h2'), 'foo')
// https://github.com/nodejs/undici/issues/2415
t.throws(() => {
response.headers.get(':status')
}, TypeError)

// See https://fetch.spec.whatwg.org/#concept-response-status-message
t.equal(response.statusText, '')
Expand Down
Loading