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

[pull] main from remix-run:main #2

Merged
merged 5 commits into from
Dec 10, 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
2 changes: 1 addition & 1 deletion packages/blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"repository": "https://github.com/remix-run/web-std-io",
"license": "MIT",
"devDependencies": {
"@remix-run/web-fetch": "^4.4.0",
"@remix-run/web-fetch": "^4.4.2-pre.0",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
Expand Down
6 changes: 6 additions & 0 deletions packages/fetch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 4.4.2

### Patch Changes

- Support HTTP2 pseudo-headers like `:authority`, `:method`, etc. ([#55](https://github.com/remix-run/web-std-io/pull/55))

## 4.4.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@remix-run/web-fetch",
"version": "4.4.1",
"version": "4.4.2",
"description": "Web API compatible fetch implementation",
"main": "./dist/lib.node.cjs",
"module": "./src/lib.node.js",
Expand Down
26 changes: 12 additions & 14 deletions packages/fetch/src/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ 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 :
Expand Down
13 changes: 13 additions & 0 deletions packages/fetch/test/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"repository": "https://github.com/remix-run/web-std-io",
"license": "MIT",
"devDependencies": {
"@remix-run/web-fetch": "^4.4.0",
"@remix-run/web-fetch": "^4.4.2-pre.0",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/form-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"license": "MIT",
"devDependencies": {
"@remix-run/web-blob": "^3.1.0",
"@remix-run/web-fetch": "^4.4.0",
"@remix-run/web-fetch": "^4.4.2-pre.0",
"@remix-run/web-file": "^3.1.0",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
Expand Down