From e55e8cf7f324ca4058defc4f1d800d80cf4ccbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 7 Apr 2025 10:51:38 +0200 Subject: [PATCH 1/3] fix(CI): stop testing on Node 14 --- .github/workflows/blob.yml | 3 ++- .github/workflows/fetch.yml | 16 ++-------------- .github/workflows/file.yml | 3 ++- .github/workflows/form-data.yml | 3 ++- .github/workflows/stream.yml | 4 +++- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.github/workflows/blob.yml b/.github/workflows/blob.yml index c147ad9c..8346c0db 100644 --- a/.github/workflows/blob.yml +++ b/.github/workflows/blob.yml @@ -17,6 +17,7 @@ jobs: name: Typecheck runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 @@ -42,9 +43,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 14 - 16 os: - ubuntu-latest diff --git a/.github/workflows/fetch.yml b/.github/workflows/fetch.yml index 663430c7..65d022fc 100644 --- a/.github/workflows/fetch.yml +++ b/.github/workflows/fetch.yml @@ -18,6 +18,7 @@ jobs: name: Typecheck runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 @@ -44,9 +45,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 14 - 16 os: - ubuntu-latest @@ -54,12 +55,6 @@ jobs: - macos-latest project: - fetch - exclude: - - os: windows-latest - node-version: 14 - # On macOS, run tests with only the LTS environments. - - os: macos-latest - node-version: 14 steps: - uses: actions/checkout@v2 @@ -75,12 +70,5 @@ jobs: - name: Test (ESM) run: yarn --cwd packages/${{matrix.project}} test -- --colors - # upload coverage only once - - name: Coveralls - uses: coverallsapp/github-action@master - if: matrix.node == '14' && matrix.os == 'ubuntu-latest' - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - - name: Test (CJS) run: yarn --cwd packages/${{matrix.project}} test:cjs diff --git a/.github/workflows/file.yml b/.github/workflows/file.yml index 5ffe24c1..04c49b8e 100644 --- a/.github/workflows/file.yml +++ b/.github/workflows/file.yml @@ -17,6 +17,7 @@ jobs: name: Typecheck runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 @@ -42,9 +43,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 14 - 16 os: - ubuntu-latest diff --git a/.github/workflows/form-data.yml b/.github/workflows/form-data.yml index 6238204b..0cf3ada8 100644 --- a/.github/workflows/form-data.yml +++ b/.github/workflows/form-data.yml @@ -18,6 +18,7 @@ jobs: name: Typecheck runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 @@ -43,9 +44,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 14 - 16 os: - ubuntu-latest diff --git a/.github/workflows/stream.yml b/.github/workflows/stream.yml index e93c5349..321ef927 100644 --- a/.github/workflows/stream.yml +++ b/.github/workflows/stream.yml @@ -17,6 +17,7 @@ jobs: name: Typecheck runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 @@ -43,9 +44,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: node-version: - - 14 - 16 os: - ubuntu-latest @@ -76,6 +77,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: - 16 From 54a5565004949080fe9712648ad55a9b608c0d45 Mon Sep 17 00:00:00 2001 From: Pedro Cattori Date: Tue, 5 Dec 2023 23:58:46 +0100 Subject: [PATCH 2/3] Add support for HTTP2 pseudo headers (#55) * fix(headers): do not depend on `http` for header name validation Node internally uses undici instead anyway * fix(headers): support HTTP2 pseudo-headers which begin with `:` e.g. `:authority`, `:method`, etc. * test(headers): check that pseudo-headers are allowed --- .changeset/wise-dogs-clean.md | 5 +++++ packages/fetch/src/headers.js | 38 ++++++++++++++++------------------ packages/fetch/test/headers.js | 13 ++++++++++++ 3 files changed, 36 insertions(+), 20 deletions(-) create mode 100644 .changeset/wise-dogs-clean.md diff --git a/.changeset/wise-dogs-clean.md b/.changeset/wise-dogs-clean.md new file mode 100644 index 00000000..b9fce005 --- /dev/null +++ b/.changeset/wise-dogs-clean.md @@ -0,0 +1,5 @@ +--- +"@remix-run/web-fetch": patch +--- + +Support HTTP2 pseudo-headers like `:authority`, `:method`, etc. diff --git a/packages/fetch/src/headers.js b/packages/fetch/src/headers.js index e1fb035a..95a08d22 100644 --- a/packages/fetch/src/headers.js +++ b/packages/fetch/src/headers.js @@ -8,27 +8,25 @@ import {types} from 'util'; import http from 'http'; import { isIterable } from './utils/is.js' -const validators = /** @type {{validateHeaderName?:(name:string) => any, validateHeaderValue?:(name:string, value:string) => any}} */ -(http) +/** @type {{validateHeaderValue?:(name:string, value:string) => any}} */ +const validators = (http) -const validateHeaderName = typeof validators.validateHeaderName === 'function' ? - validators.validateHeaderName : - /** - * @param {string} name - */ - name => { - if (!/^[\^`\-\w!#$%&'*+.|~]+$/.test(name)) { - const err = new TypeError(`Header name must be a valid HTTP token [${name}]`); - Object.defineProperty(err, 'code', {value: 'ERR_INVALID_HTTP_TOKEN'}); - throw err; - } - }; +/** + * @param {string} name + */ +const validateHeaderName = name => { + if (!/^[\^`\-\w!#$%&'*+.|~:]+$/.test(name)) { + const err = new TypeError(`Header name must be a valid HTTP token [${name}]`); + Object.defineProperty(err, 'code', {value: 'ERR_INVALID_HTTP_TOKEN'}); + throw err; + } +}; const validateHeaderValue = typeof validators.validateHeaderValue === 'function' ? validators.validateHeaderValue : /** - * @param {string} name - * @param {string} value + * @param {string} name + * @param {string} value */ (name, value) => { if (/[^\t\u0020-\u007E\u0080-\u00FF]/.test(value)) { @@ -166,8 +164,8 @@ export default class Headers extends URLSearchParams { } /** - * - * @param {string} name + * + * @param {string} name */ get(name) { const values = this.getAll(name); @@ -184,8 +182,8 @@ export default class Headers extends URLSearchParams { } /** - * @param {(value: string, key: string, parent: this) => void} callback - * @param {any} thisArg + * @param {(value: string, key: string, parent: this) => void} callback + * @param {any} thisArg * @returns {void} */ forEach(callback, thisArg = undefined) { diff --git a/packages/fetch/test/headers.js b/packages/fetch/test/headers.js index beed9d9e..6078edac 100644 --- a/packages/fetch/test/headers.js +++ b/packages/fetch/test/headers.js @@ -216,6 +216,19 @@ describe('Headers', () => { expect(() => headers.append('', 'ok')).to.throw(TypeError); }); + it('should allow HTTP2 pseudo-headers', () => { + let headers = new Headers({':authority': 'something'}); + headers.append(":method", "something else") + + const result = []; + for (const pair of headers) { + result.push(pair); + } + + expect(result).to.deep.equal([[':authority', 'something'], [':method', 'something else']]); + + }) + it('should ignore unsupported attributes while reading headers', () => { const FakeHeader = function () { }; // Prototypes are currently ignored From 71dfe89be1b9d511b4c6e5017c72aef5917b2d41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 7 Apr 2025 13:51:30 +0200 Subject: [PATCH 3/3] chore: fix changeset --- .changeset/wise-dogs-clean.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/wise-dogs-clean.md b/.changeset/wise-dogs-clean.md index b9fce005..c5f922b6 100644 --- a/.changeset/wise-dogs-clean.md +++ b/.changeset/wise-dogs-clean.md @@ -1,5 +1,5 @@ --- -"@remix-run/web-fetch": patch +"@web-std/fetch": patch --- Support HTTP2 pseudo-headers like `:authority`, `:method`, etc.