Skip to content

Commit

Permalink
Merge branch 'main' into websocketstream-again
Browse files Browse the repository at this point in the history
  • Loading branch information
KhafraDev authored Sep 25, 2024
2 parents 2f37e60 + e6e87c1 commit d45cac7
Show file tree
Hide file tree
Showing 70 changed files with 1,356 additions and 748 deletions.
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint
4 changes: 2 additions & 2 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
},
"dependencies": {
"axios": "^1.6.7",
"concurrently": "^8.2.2",
"concurrently": "^9.0.0",
"cronometro": "^3.0.1",
"got": "^14.2.0",
"mitata": "^0.1.11",
"mitata": "^1.0.4",
"node-fetch": "^3.3.2",
"request": "^2.88.2",
"superagent": "^10.0.0",
Expand Down
2 changes: 1 addition & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:22-alpine3.19@sha256:ef7b4bbf1eefd881fa3c30c296f29f07f33ea9ec6a8ab7e57778ab2e24d7959d
FROM node:22-alpine3.19@sha256:3cb4748ed93c45cf4622c3382a5ce063af1fcbc5f3da6d2b669352ebace9f76d

ARG UID=1000
ARG GID=1000
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/api/Client.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Returns: `Client`

> ⚠️ Warning: The `H2` support is experimental.
* **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. Please note the `timeout` will be reset if you keep writing data to the scoket everytime.
* **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. Please note the `timeout` will be reset if you keep writing data to the socket everytime.
* **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds.
* **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Defaults to 10 minutes.
* **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds.
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/proxy/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { Pool, Client } = require('../../../')
const http = require('node:http')
const proxy = require('./proxy')
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/proxy/websocket.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { Pool, Client } = require('../../../')
const http = require('node:http')
const proxy = require('./proxy')
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ module.exports.setGlobalOrigin = setGlobalOrigin
module.exports.getGlobalOrigin = getGlobalOrigin

const { CacheStorage } = require('./lib/web/cache/cachestorage')
const { kConstruct } = require('./lib/web/cache/symbols')
const { kConstruct } = require('./lib/core/symbols')

// Cache & CacheStorage are tightly coupled with fetch. Even if it may run
// in an older version of Node, it doesn't have any use without fetch.
Expand Down
2 changes: 2 additions & 0 deletions lib/api/abort-signal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const { addAbortListener } = require('../core/util')
const { RequestAbortedError } = require('../core/errors')

Expand Down
2 changes: 2 additions & 0 deletions lib/api/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const assert = require('node:assert')
const {
ResponseStatusCodeError
Expand Down
20 changes: 11 additions & 9 deletions lib/core/constants.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use strict'

/** @type {Record<string, string | undefined>} */
const headerNameLowerCasedRecord = {}

// https://developer.mozilla.org/docs/Web/HTTP/Headers
const wellknownHeaderNames = [
/**
* @see https://developer.mozilla.org/docs/Web/HTTP/Headers
*/
const wellknownHeaderNames = /** @type {const} */ ([
'Accept',
'Accept-Encoding',
'Accept-Language',
Expand Down Expand Up @@ -100,7 +99,13 @@ const wellknownHeaderNames = [
'X-Powered-By',
'X-Requested-With',
'X-XSS-Protection'
]
])

/** @type {Record<typeof wellknownHeaderNames[number]|Lowercase<typeof wellknownHeaderNames[number]>, string>} */
const headerNameLowerCasedRecord = {}

// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
Object.setPrototypeOf(headerNameLowerCasedRecord, null)

for (let i = 0; i < wellknownHeaderNames.length; ++i) {
const key = wellknownHeaderNames[i]
Expand All @@ -109,9 +114,6 @@ for (let i = 0; i < wellknownHeaderNames.length; ++i) {
lowerCasedKey
}

// Note: object prototypes should not be able to be referenced. e.g. `Object#hasOwnProperty`.
Object.setPrototypeOf(headerNameLowerCasedRecord, null)

module.exports = {
wellknownHeaderNames,
headerNameLowerCasedRecord
Expand Down
Loading

0 comments on commit d45cac7

Please sign in to comment.