code
stringlengths
24
2.07M
docstring
stringlengths
25
85.3k
func_name
stringlengths
1
92
language
stringclasses
1 value
repo
stringlengths
5
64
path
stringlengths
4
172
url
stringlengths
44
218
license
stringclasses
7 values
set binaryType (type) { webidl.brandCheck(this, WebSocket) if (type !== 'blob' && type !== 'arraybuffer') { this[kBinaryType] = 'blob' } else { this[kBinaryType] = type } }
@see https://websockets.spec.whatwg.org/#feedback-from-the-protocol
binaryType
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor () { if (arguments[0] !== kConstruct) { webidl.illegalConstructor() } this.#relevantRequestResponseList = arguments[1] }
@see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list @type {requestResponseList}
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async match (request, options = {}) { webidl.brandCheck(this, Cache) webidl.argumentLengthCheck(arguments, 1, { header: 'Cache.match' }) request = webidl.converters.RequestInfo(request) options = webidl.converters.CacheQueryOptions(options) const p = await this.matchAll(request, options) if (p.length === 0) { return } return p[0] }
@see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list @type {requestResponseList}
match
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async matchAll (request = undefined, options = {}) { webidl.brandCheck(this, Cache) if (request !== undefined) request = webidl.converters.RequestInfo(request) options = webidl.converters.CacheQueryOptions(options) // 1. let r = null // 2. if (request !== undefined) { if (request instanceof Request) { // 2.1.1 r = request[kState] // 2.1.2 if (r.method !== 'GET' && !options.ignoreMethod) { return [] } } else if (typeof request === 'string') { // 2.2.1 r = new Request(request)[kState] } } // 5. // 5.1 const responses = [] // 5.2 if (request === undefined) { // 5.2.1 for (const requestResponse of this.#relevantRequestResponseList) { responses.push(requestResponse[1]) } } else { // 5.3 // 5.3.1 const requestResponses = this.#queryCache(r, options) // 5.3.2 for (const requestResponse of requestResponses) { responses.push(requestResponse[1]) } } // 5.4 // We don't implement CORs so we don't need to loop over the responses, yay! // 5.5.1 const responseList = [] // 5.5.2 for (const response of responses) { // 5.5.2.1 const responseObject = new Response(response.body?.source ?? null) const body = responseObject[kState].body responseObject[kState] = response responseObject[kState].body = body responseObject[kHeaders][kHeadersList] = response.headersList responseObject[kHeaders][kGuard] = 'immutable' responseList.push(responseObject) } // 6. return Object.freeze(responseList) }
@see https://w3c.github.io/ServiceWorker/#dfn-relevant-request-response-list @type {requestResponseList}
matchAll
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async keys (request = undefined, options = {}) { webidl.brandCheck(this, Cache) if (request !== undefined) request = webidl.converters.RequestInfo(request) options = webidl.converters.CacheQueryOptions(options) // 1. let r = null // 2. if (request !== undefined) { // 2.1 if (request instanceof Request) { // 2.1.1 r = request[kState] // 2.1.2 if (r.method !== 'GET' && !options.ignoreMethod) { return [] } } else if (typeof request === 'string') { // 2.2 r = new Request(request)[kState] } } // 4. const promise = createDeferredPromise() // 5. // 5.1 const requests = [] // 5.2 if (request === undefined) { // 5.2.1 for (const requestResponse of this.#relevantRequestResponseList) { // 5.2.1.1 requests.push(requestResponse[0]) } } else { // 5.3 // 5.3.1 const requestResponses = this.#queryCache(r, options) // 5.3.2 for (const requestResponse of requestResponses) { // 5.3.2.1 requests.push(requestResponse[0]) } } // 5.4 queueMicrotask(() => { // 5.4.1 const requestList = [] // 5.4.2 for (const request of requests) { const requestObject = new Request('https://a') requestObject[kState] = request requestObject[kHeaders][kHeadersList] = request.headersList requestObject[kHeaders][kGuard] = 'immutable' requestObject[kRealm] = request.client // 5.4.2.1 requestList.push(requestObject) } // 5.4.3 promise.resolve(Object.freeze(requestList)) }) return promise.promise }
@see https://w3c.github.io/ServiceWorker/#dom-cache-keys @param {any} request @param {import('../../types/cache').CacheQueryOptions} options @returns {readonly Request[]}
keys
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor () { if (arguments[0] !== kConstruct) { webidl.illegalConstructor() } }
@see https://w3c.github.io/ServiceWorker/#cache-storage-has @param {string} cacheName @returns {Promise<boolean>}
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async match (request, options = {}) { webidl.brandCheck(this, CacheStorage) webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.match' }) request = webidl.converters.RequestInfo(request) options = webidl.converters.MultiCacheQueryOptions(options) // 1. if (options.cacheName != null) { // 1.1.1.1 if (this.#caches.has(options.cacheName)) { // 1.1.1.1.1 const cacheList = this.#caches.get(options.cacheName) const cache = new Cache(kConstruct, cacheList) return await cache.match(request, options) } } else { // 2. // 2.2 for (const cacheList of this.#caches.values()) { const cache = new Cache(kConstruct, cacheList) // 2.2.1.2 const response = await cache.match(request, options) if (response !== undefined) { return response } } } }
@see https://w3c.github.io/ServiceWorker/#cache-storage-has @param {string} cacheName @returns {Promise<boolean>}
match
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async has (cacheName) { webidl.brandCheck(this, CacheStorage) webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.has' }) cacheName = webidl.converters.DOMString(cacheName) // 2.1.1 // 2.2 return this.#caches.has(cacheName) }
@see https://w3c.github.io/ServiceWorker/#cache-storage-delete @param {string} cacheName @returns {Promise<boolean>}
has
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async open (cacheName) { webidl.brandCheck(this, CacheStorage) webidl.argumentLengthCheck(arguments, 1, { header: 'CacheStorage.open' }) cacheName = webidl.converters.DOMString(cacheName) // 2.1 if (this.#caches.has(cacheName)) { // await caches.open('v1') !== await caches.open('v1') // 2.1.1 const cache = this.#caches.get(cacheName) // 2.1.1.1 return new Cache(kConstruct, cache) } // 2.2 const cache = [] // 2.3 this.#caches.set(cacheName, cache) // 2.4 return new Cache(kConstruct, cache) }
@see https://w3c.github.io/ServiceWorker/#cache-storage-keys @returns {string[]}
open
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async keys () { webidl.brandCheck(this, CacheStorage) // 2.1 const keys = this.#caches.keys() // 2.2 return [...keys] }
@see https://url.spec.whatwg.org/#concept-url-equals @param {URL} A @param {URL} B @param {boolean | undefined} excludeFragment @returns {boolean}
keys
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (url, { interceptors, maxHeaderSize, headersTimeout, socketTimeout, requestTimeout, connectTimeout, bodyTimeout, idleTimeout, keepAlive, keepAliveTimeout, maxKeepAliveTimeout, keepAliveMaxTimeout, keepAliveTimeoutThreshold, socketPath, pipelining, tls, strictContentLength, maxCachedSessions, maxRedirections, connect, maxRequestsPerClient, localAddress, maxResponseSize, autoSelectFamily, autoSelectFamilyAttemptTimeout, // h2 allowH2, maxConcurrentStreams } = {}) { super() if (keepAlive !== undefined) { throw new InvalidArgumentError('unsupported keepAlive, use pipelining=0 instead') } if (socketTimeout !== undefined) { throw new InvalidArgumentError('unsupported socketTimeout, use headersTimeout & bodyTimeout instead') } if (requestTimeout !== undefined) { throw new InvalidArgumentError('unsupported requestTimeout, use headersTimeout & bodyTimeout instead') } if (idleTimeout !== undefined) { throw new InvalidArgumentError('unsupported idleTimeout, use keepAliveTimeout instead') } if (maxKeepAliveTimeout !== undefined) { throw new InvalidArgumentError('unsupported maxKeepAliveTimeout, use keepAliveMaxTimeout instead') } if (maxHeaderSize != null && !Number.isFinite(maxHeaderSize)) { throw new InvalidArgumentError('invalid maxHeaderSize') } if (socketPath != null && typeof socketPath !== 'string') { throw new InvalidArgumentError('invalid socketPath') } if (connectTimeout != null && (!Number.isFinite(connectTimeout) || connectTimeout < 0)) { throw new InvalidArgumentError('invalid connectTimeout') } if (keepAliveTimeout != null && (!Number.isFinite(keepAliveTimeout) || keepAliveTimeout <= 0)) { throw new InvalidArgumentError('invalid keepAliveTimeout') } if (keepAliveMaxTimeout != null && (!Number.isFinite(keepAliveMaxTimeout) || keepAliveMaxTimeout <= 0)) { throw new InvalidArgumentError('invalid keepAliveMaxTimeout') } if (keepAliveTimeoutThreshold != null && !Number.isFinite(keepAliveTimeoutThreshold)) { throw new InvalidArgumentError('invalid keepAliveTimeoutThreshold') } if (headersTimeout != null && (!Number.isInteger(headersTimeout) || headersTimeout < 0)) { throw new InvalidArgumentError('headersTimeout must be a positive integer or zero') } if (bodyTimeout != null && (!Number.isInteger(bodyTimeout) || bodyTimeout < 0)) { throw new InvalidArgumentError('bodyTimeout must be a positive integer or zero') } if (connect != null && typeof connect !== 'function' && typeof connect !== 'object') { throw new InvalidArgumentError('connect must be a function or an object') } if (maxRedirections != null && (!Number.isInteger(maxRedirections) || maxRedirections < 0)) { throw new InvalidArgumentError('maxRedirections must be a positive number') } if (maxRequestsPerClient != null && (!Number.isInteger(maxRequestsPerClient) || maxRequestsPerClient < 0)) { throw new InvalidArgumentError('maxRequestsPerClient must be a positive number') } if (localAddress != null && (typeof localAddress !== 'string' || net.isIP(localAddress) === 0)) { throw new InvalidArgumentError('localAddress must be valid string IP address') } if (maxResponseSize != null && (!Number.isInteger(maxResponseSize) || maxResponseSize < -1)) { throw new InvalidArgumentError('maxResponseSize must be a positive number') } if ( autoSelectFamilyAttemptTimeout != null && (!Number.isInteger(autoSelectFamilyAttemptTimeout) || autoSelectFamilyAttemptTimeout < -1) ) { throw new InvalidArgumentError('autoSelectFamilyAttemptTimeout must be a positive number') } // h2 if (allowH2 != null && typeof allowH2 !== 'boolean') { throw new InvalidArgumentError('allowH2 must be a valid boolean value') } if (maxConcurrentStreams != null && (typeof maxConcurrentStreams !== 'number' || maxConcurrentStreams < 1)) { throw new InvalidArgumentError('maxConcurrentStreams must be a possitive integer, greater than 0') } if (typeof connect !== 'function') { connect = buildConnector({ ...tls, maxCachedSessions, allowH2, socketPath, timeout: connectTimeout, ...(util.nodeHasAutoSelectFamily && autoSelectFamily ? { autoSelectFamily, autoSelectFamilyAttemptTimeout } : undefined), ...connect }) } this[kInterceptors] = interceptors && interceptors.Client && Array.isArray(interceptors.Client) ? interceptors.Client : [createRedirectInterceptor({ maxRedirections })] this[kUrl] = util.parseOrigin(url) this[kConnector] = connect this[kSocket] = null this[kPipelining] = pipelining != null ? pipelining : 1 this[kMaxHeadersSize] = maxHeaderSize || http.maxHeaderSize this[kKeepAliveDefaultTimeout] = keepAliveTimeout == null ? 4e3 : keepAliveTimeout this[kKeepAliveMaxTimeout] = keepAliveMaxTimeout == null ? 600e3 : keepAliveMaxTimeout this[kKeepAliveTimeoutThreshold] = keepAliveTimeoutThreshold == null ? 1e3 : keepAliveTimeoutThreshold this[kKeepAliveTimeoutValue] = this[kKeepAliveDefaultTimeout] this[kServerName] = null this[kLocalAddress] = localAddress != null ? localAddress : null this[kResuming] = 0 // 0, idle, 1, scheduled, 2 resuming this[kNeedDrain] = 0 // 0, idle, 1, scheduled, 2 resuming this[kHostHeader] = `host: ${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}\r\n` this[kBodyTimeout] = bodyTimeout != null ? bodyTimeout : 300e3 this[kHeadersTimeout] = headersTimeout != null ? headersTimeout : 300e3 this[kStrictContentLength] = strictContentLength == null ? true : strictContentLength this[kMaxRedirections] = maxRedirections this[kMaxRequests] = maxRequestsPerClient this[kClosedResolve] = null this[kMaxResponseSize] = maxResponseSize > -1 ? maxResponseSize : -1 this[kHTTPConnVersion] = 'h1' // HTTP/2 this[kHTTP2Session] = null this[kHTTP2SessionState] = !allowH2 ? null : { // streams: null, // Fixed queue of streams - For future support of `push` openStreams: 0, // Keep track of them to decide wether or not unref the session maxConcurrentStreams: maxConcurrentStreams != null ? maxConcurrentStreams : 100 // Max peerConcurrentStreams for a Node h2 server } this[kHost] = `${this[kUrl].hostname}${this[kUrl].port ? `:${this[kUrl].port}` : ''}` // kQueue is built up of 3 sections separated by // the kRunningIdx and kPendingIdx indices. // | complete | running | pending | // ^ kRunningIdx ^ kPendingIdx ^ kQueue.length // kRunningIdx points to the first running element. // kPendingIdx points to the first pending element. // This implements a fast queue with an amortized // time of O(1). this[kQueue] = [] this[kRunningIdx] = 0 this[kPendingIdx] = 0 }
@param {string|URL} url @param {import('../types/client').Client.Options} options
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
get pipelining () { return this[kPipelining] }
@param {string|URL} url @param {import('../types/client').Client.Options} options
pipelining
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
set pipelining (value) { this[kPipelining] = value resume(this, true) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
pipelining
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
callback = () => { if (this[kClosedResolve]) { // TODO (fix): Should we error here with ClientDestroyedError? this[kClosedResolve]() this[kClosedResolve] = null } resolve() }
@param {string|URL} url @param {import('../types/client').Client.Options} options
callback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
callback = () => { if (this[kClosedResolve]) { // TODO (fix): Should we error here with ClientDestroyedError? this[kClosedResolve]() this[kClosedResolve] = null } resolve() }
@param {string|URL} url @param {import('../types/client').Client.Options} options
callback
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onHttp2SessionError (err) { assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID') this[kSocket][kError] = err onError(this[kClient], err) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHttp2SessionError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onHttp2FrameError (type, code, id) { const err = new InformationalError(`HTTP/2: "frameError" received - type ${type}, code ${code}`) if (id === 0) { this[kSocket][kError] = err onError(this[kClient], err) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHttp2FrameError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onHttp2SessionEnd () { util.destroy(this, new SocketError('other side closed')) util.destroy(this[kSocket], new SocketError('other side closed')) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHttp2SessionEnd
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onHTTP2GoAway (code) { const client = this[kClient] const err = new InformationalError(`HTTP/2: "GOAWAY" frame received with code ${code}`) client[kSocket] = null client[kHTTP2Session] = null if (client.destroyed) { assert(this[kPending] === 0) // Fail entire queue. const requests = client[kQueue].splice(client[kRunningIdx]) for (let i = 0; i < requests.length; i++) { const request = requests[i] errorRequest(this, request, err) } } else if (client[kRunning] > 0) { // Fail head of pipeline. const request = client[kQueue][client[kRunningIdx]] client[kQueue][client[kRunningIdx]++] = null errorRequest(client, request, err) } client[kPendingIdx] = client[kRunningIdx] assert(client[kRunning] === 0) client.emit('disconnect', client[kUrl], [client], err ) resume(client) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHTTP2GoAway
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async function lazyllhttp () { const llhttpWasmData = process.env.JEST_WORKER_ID ? __nccwpck_require__(2745) : undefined let mod try { mod = await WebAssembly.compile(Buffer.from(__nccwpck_require__(3643), 'base64')) } catch (e) { /* istanbul ignore next */ // We could check if the error was caused by the simd option not // being enabled, but the occurring of this other error // * https://github.com/emscripten-core/emscripten/issues/11495 // got me to remove that check to avoid breaking Node 12. mod = await WebAssembly.compile(Buffer.from(llhttpWasmData || __nccwpck_require__(2745), 'base64')) } return await WebAssembly.instantiate(mod, { env: { /* eslint-disable camelcase */ wasm_on_url: (p, at, len) => { /* istanbul ignore next */ return 0 }, wasm_on_status: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onStatus(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_message_begin: (p) => { assert.strictEqual(currentParser.ptr, p) return currentParser.onMessageBegin() || 0 }, wasm_on_header_field: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onHeaderField(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_header_value: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onHeaderValue(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_headers_complete: (p, statusCode, upgrade, shouldKeepAlive) => { assert.strictEqual(currentParser.ptr, p) return currentParser.onHeadersComplete(statusCode, Boolean(upgrade), Boolean(shouldKeepAlive)) || 0 }, wasm_on_body: (p, at, len) => { assert.strictEqual(currentParser.ptr, p) const start = at - currentBufferPtr + currentBufferRef.byteOffset return currentParser.onBody(new FastBuffer(currentBufferRef.buffer, start, len)) || 0 }, wasm_on_message_complete: (p) => { assert.strictEqual(currentParser.ptr, p) return currentParser.onMessageComplete() || 0 } /* eslint-enable camelcase */ } }) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
lazyllhttp
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (client, socket, { exports }) { assert(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0) this.llhttp = exports this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE) this.client = client this.socket = socket this.timeout = null this.timeoutValue = null this.timeoutType = null this.statusCode = null this.statusText = '' this.upgrade = false this.headers = [] this.headersSize = 0 this.headersMaxSize = client[kMaxHeadersSize] this.shouldKeepAlive = false this.paused = false this.resume = this.resume.bind(this) this.bytesRead = 0 this.keepAlive = '' this.contentLength = '' this.connection = '' this.maxResponseSize = client[kMaxResponseSize] }
@param {string|URL} url @param {import('../types/client').Client.Options} options
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
setTimeout (value, type) { this.timeoutType = type if (value !== this.timeoutValue) { timers.clearTimeout(this.timeout) if (value) { this.timeout = timers.setTimeout(onParserTimeout, value, this) // istanbul ignore else: only for jest if (this.timeout.unref) { this.timeout.unref() } } else { this.timeout = null } this.timeoutValue = value } else if (this.timeout) { // istanbul ignore else: only for jest if (this.timeout.refresh) { this.timeout.refresh() } } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
setTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
resume () { if (this.socket.destroyed || !this.paused) { return } assert(this.ptr != null) assert(currentParser == null) this.llhttp.llhttp_resume(this.ptr) assert(this.timeoutType === TIMEOUT_BODY) if (this.timeout) { // istanbul ignore else: only for jest if (this.timeout.refresh) { this.timeout.refresh() } } this.paused = false this.execute(this.socket.read() || EMPTY_BUF) // Flush parser. this.readMore() }
@param {string|URL} url @param {import('../types/client').Client.Options} options
resume
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
readMore () { while (!this.paused && this.ptr) { const chunk = this.socket.read() if (chunk === null) { break } this.execute(chunk) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
readMore
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
execute (data) { assert(this.ptr != null) assert(currentParser == null) assert(!this.paused) const { socket, llhttp } = this if (data.length > currentBufferSize) { if (currentBufferPtr) { llhttp.free(currentBufferPtr) } currentBufferSize = Math.ceil(data.length / 4096) * 4096 currentBufferPtr = llhttp.malloc(currentBufferSize) } new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize).set(data) // Call `execute` on the wasm parser. // We pass the `llhttp_parser` pointer address, the pointer address of buffer view data, // and finally the length of bytes to parse. // The return value is an error code or `constants.ERROR.OK`. try { let ret try { currentBufferRef = data currentParser = this ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, data.length) /* eslint-disable-next-line no-useless-catch */ } catch (err) { /* istanbul ignore next: difficult to make a test case for */ throw err } finally { currentParser = null currentBufferRef = null } const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr if (ret === constants.ERROR.PAUSED_UPGRADE) { this.onUpgrade(data.slice(offset)) } else if (ret === constants.ERROR.PAUSED) { this.paused = true socket.unshift(data.slice(offset)) } else if (ret !== constants.ERROR.OK) { const ptr = llhttp.llhttp_get_error_reason(this.ptr) let message = '' /* istanbul ignore else: difficult to make a test case for */ if (ptr) { const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0) message = 'Response does not match the HTTP/1.1 protocol (' + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ')' } throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset)) } } catch (err) { util.destroy(socket, err) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
execute
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
destroy () { assert(this.ptr != null) assert(currentParser == null) this.llhttp.llhttp_free(this.ptr) this.ptr = null timers.clearTimeout(this.timeout) this.timeout = null this.timeoutValue = null this.timeoutType = null this.paused = false }
@param {string|URL} url @param {import('../types/client').Client.Options} options
destroy
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onStatus (buf) { this.statusText = buf.toString() }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onStatus
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onMessageBegin () { const { socket, client } = this /* istanbul ignore next: difficult to make a test case for */ if (socket.destroyed) { return -1 } const request = client[kQueue][client[kRunningIdx]] if (!request) { return -1 } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onMessageBegin
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onHeaderField (buf) { const len = this.headers.length if ((len & 1) === 0) { this.headers.push(buf) } else { this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf]) } this.trackHeader(buf.length) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHeaderField
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onHeaderValue (buf) { let len = this.headers.length if ((len & 1) === 1) { this.headers.push(buf) len += 1 } else { this.headers[len - 1] = Buffer.concat([this.headers[len - 1], buf]) } const key = this.headers[len - 2] if (key.length === 10 && key.toString().toLowerCase() === 'keep-alive') { this.keepAlive += buf.toString() } else if (key.length === 10 && key.toString().toLowerCase() === 'connection') { this.connection += buf.toString() } else if (key.length === 14 && key.toString().toLowerCase() === 'content-length') { this.contentLength += buf.toString() } this.trackHeader(buf.length) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHeaderValue
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
trackHeader (len) { this.headersSize += len if (this.headersSize >= this.headersMaxSize) { util.destroy(this.socket, new HeadersOverflowError()) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
trackHeader
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onUpgrade (head) { const { upgrade, client, socket, headers, statusCode } = this assert(upgrade) const request = client[kQueue][client[kRunningIdx]] assert(request) assert(!socket.destroyed) assert(socket === client[kSocket]) assert(!this.paused) assert(request.upgrade || request.method === 'CONNECT') this.statusCode = null this.statusText = '' this.shouldKeepAlive = null assert(this.headers.length % 2 === 0) this.headers = [] this.headersSize = 0 socket.unshift(head) socket[kParser].destroy() socket[kParser] = null socket[kClient] = null socket[kError] = null socket .removeListener('error', onSocketError) .removeListener('readable', onSocketReadable) .removeListener('end', onSocketEnd) .removeListener('close', onSocketClose) client[kSocket] = null client[kQueue][client[kRunningIdx]++] = null client.emit('disconnect', client[kUrl], [client], new InformationalError('upgrade')) try { request.onUpgrade(statusCode, headers, socket) } catch (err) { util.destroy(socket, err) } resume(client) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onUpgrade
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onHeadersComplete (statusCode, upgrade, shouldKeepAlive) { const { client, socket, headers, statusText } = this /* istanbul ignore next: difficult to make a test case for */ if (socket.destroyed) { return -1 } const request = client[kQueue][client[kRunningIdx]] /* istanbul ignore next: difficult to make a test case for */ if (!request) { return -1 } assert(!this.upgrade) assert(this.statusCode < 200) if (statusCode === 100) { util.destroy(socket, new SocketError('bad response', util.getSocketInfo(socket))) return -1 } /* this can only happen if server is misbehaving */ if (upgrade && !request.upgrade) { util.destroy(socket, new SocketError('bad upgrade', util.getSocketInfo(socket))) return -1 } assert.strictEqual(this.timeoutType, TIMEOUT_HEADERS) this.statusCode = statusCode this.shouldKeepAlive = ( shouldKeepAlive || // Override llhttp value which does not allow keepAlive for HEAD. (request.method === 'HEAD' && !socket[kReset] && this.connection.toLowerCase() === 'keep-alive') ) if (this.statusCode >= 200) { const bodyTimeout = request.bodyTimeout != null ? request.bodyTimeout : client[kBodyTimeout] this.setTimeout(bodyTimeout, TIMEOUT_BODY) } else if (this.timeout) { // istanbul ignore else: only for jest if (this.timeout.refresh) { this.timeout.refresh() } } if (request.method === 'CONNECT') { assert(client[kRunning] === 1) this.upgrade = true return 2 } if (upgrade) { assert(client[kRunning] === 1) this.upgrade = true return 2 } assert(this.headers.length % 2 === 0) this.headers = [] this.headersSize = 0 if (this.shouldKeepAlive && client[kPipelining]) { const keepAliveTimeout = this.keepAlive ? util.parseKeepAliveTimeout(this.keepAlive) : null if (keepAliveTimeout != null) { const timeout = Math.min( keepAliveTimeout - client[kKeepAliveTimeoutThreshold], client[kKeepAliveMaxTimeout] ) if (timeout <= 0) { socket[kReset] = true } else { client[kKeepAliveTimeoutValue] = timeout } } else { client[kKeepAliveTimeoutValue] = client[kKeepAliveDefaultTimeout] } } else { // Stop more requests from being dispatched. socket[kReset] = true } const pause = request.onHeaders(statusCode, headers, this.resume, statusText) === false if (request.aborted) { return -1 } if (request.method === 'HEAD') { return 1 } if (statusCode < 200) { return 1 } if (socket[kBlocking]) { socket[kBlocking] = false resume(client) } return pause ? constants.ERROR.PAUSED : 0 }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onHeadersComplete
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onBody (buf) { const { client, socket, statusCode, maxResponseSize } = this if (socket.destroyed) { return -1 } const request = client[kQueue][client[kRunningIdx]] assert(request) assert.strictEqual(this.timeoutType, TIMEOUT_BODY) if (this.timeout) { // istanbul ignore else: only for jest if (this.timeout.refresh) { this.timeout.refresh() } } assert(statusCode >= 200) if (maxResponseSize > -1 && this.bytesRead + buf.length > maxResponseSize) { util.destroy(socket, new ResponseExceededMaxSizeError()) return -1 } this.bytesRead += buf.length if (request.onData(buf) === false) { return constants.ERROR.PAUSED } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onBody
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onMessageComplete () { const { client, socket, statusCode, upgrade, headers, contentLength, bytesRead, shouldKeepAlive } = this if (socket.destroyed && (!statusCode || shouldKeepAlive)) { return -1 } if (upgrade) { return } const request = client[kQueue][client[kRunningIdx]] assert(request) assert(statusCode >= 100) this.statusCode = null this.statusText = '' this.bytesRead = 0 this.contentLength = '' this.keepAlive = '' this.connection = '' assert(this.headers.length % 2 === 0) this.headers = [] this.headersSize = 0 if (statusCode < 200) { return } /* istanbul ignore next: should be handled by llhttp? */ if (request.method !== 'HEAD' && contentLength && bytesRead !== parseInt(contentLength, 10)) { util.destroy(socket, new ResponseContentLengthMismatchError()) return -1 } request.onComplete(headers) client[kQueue][client[kRunningIdx]++] = null if (socket[kWriting]) { assert.strictEqual(client[kRunning], 0) // Response completed before request. util.destroy(socket, new InformationalError('reset')) return constants.ERROR.PAUSED } else if (!shouldKeepAlive) { util.destroy(socket, new InformationalError('reset')) return constants.ERROR.PAUSED } else if (socket[kReset] && client[kRunning] === 0) { // Destroy socket once all requests have completed. // The request at the tail of the pipeline is the one // that requested reset and no further requests should // have been queued since then. util.destroy(socket, new InformationalError('reset')) return constants.ERROR.PAUSED } else if (client[kPipelining] === 1) { // We must wait a full event loop cycle to reuse this socket to make sure // that non-spec compliant servers are not closing the connection even if they // said they won't. setImmediate(resume, client) } else { resume(client) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onMessageComplete
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onParserTimeout (parser) { const { socket, timeoutType, client } = parser /* istanbul ignore else */ if (timeoutType === TIMEOUT_HEADERS) { if (!socket[kWriting] || socket.writableNeedDrain || client[kRunning] > 1) { assert(!parser.paused, 'cannot be paused while waiting for headers') util.destroy(socket, new HeadersTimeoutError()) } } else if (timeoutType === TIMEOUT_BODY) { if (!parser.paused) { util.destroy(socket, new BodyTimeoutError()) } } else if (timeoutType === TIMEOUT_IDLE) { assert(client[kRunning] === 0 && client[kKeepAliveTimeoutValue]) util.destroy(socket, new InformationalError('socket idle timeout')) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onParserTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onSocketReadable () { const { [kParser]: parser } = this if (parser) { parser.readMore() } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onSocketReadable
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onSocketError (err) { const { [kClient]: client, [kParser]: parser } = this assert(err.code !== 'ERR_TLS_CERT_ALTNAME_INVALID') if (client[kHTTPConnVersion] !== 'h2') { // On Mac OS, we get an ECONNRESET even if there is a full body to be forwarded // to the user. if (err.code === 'ECONNRESET' && parser.statusCode && !parser.shouldKeepAlive) { // We treat all incoming data so for as a valid response. parser.onMessageComplete() return } } this[kError] = err onError(this[kClient], err) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onSocketError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onError (client, err) { if ( client[kRunning] === 0 && err.code !== 'UND_ERR_INFO' && err.code !== 'UND_ERR_SOCKET' ) { // Error is not caused by running request and not a recoverable // socket error. assert(client[kPendingIdx] === client[kRunningIdx]) const requests = client[kQueue].splice(client[kRunningIdx]) for (let i = 0; i < requests.length; i++) { const request = requests[i] errorRequest(client, request, err) } assert(client[kSize] === 0) } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onSocketEnd () { const { [kParser]: parser, [kClient]: client } = this if (client[kHTTPConnVersion] !== 'h2') { if (parser.statusCode && !parser.shouldKeepAlive) { // We treat all incoming data so far as a valid response. parser.onMessageComplete() return } } util.destroy(this, new SocketError('other side closed', util.getSocketInfo(this))) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onSocketEnd
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function onSocketClose () { const { [kClient]: client, [kParser]: parser } = this if (client[kHTTPConnVersion] === 'h1' && parser) { if (!this[kError] && parser.statusCode && !parser.shouldKeepAlive) { // We treat all incoming data so far as a valid response. parser.onMessageComplete() } this[kParser].destroy() this[kParser] = null } const err = this[kError] || new SocketError('closed', util.getSocketInfo(this)) client[kSocket] = null if (client.destroyed) { assert(client[kPending] === 0) // Fail entire queue. const requests = client[kQueue].splice(client[kRunningIdx]) for (let i = 0; i < requests.length; i++) { const request = requests[i] errorRequest(client, request, err) } } else if (client[kRunning] > 0 && err.code !== 'UND_ERR_INFO') { // Fail head of pipeline. const request = client[kQueue][client[kRunningIdx]] client[kQueue][client[kRunningIdx]++] = null errorRequest(client, request, err) } client[kPendingIdx] = client[kRunningIdx] assert(client[kRunning] === 0) client.emit('disconnect', client[kUrl], [client], err) resume(client) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
onSocketClose
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async function connect (client) { assert(!client[kConnecting]) assert(!client[kSocket]) let { host, hostname, protocol, port } = client[kUrl] // Resolve ipv6 if (hostname[0] === '[') { const idx = hostname.indexOf(']') assert(idx !== -1) const ip = hostname.substring(1, idx) assert(net.isIP(ip)) hostname = ip } client[kConnecting] = true if (channels.beforeConnect.hasSubscribers) { channels.beforeConnect.publish({ connectParams: { host, hostname, protocol, port, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector] }) } try { const socket = await new Promise((resolve, reject) => { client[kConnector]({ host, hostname, protocol, port, servername: client[kServerName], localAddress: client[kLocalAddress] }, (err, socket) => { if (err) { reject(err) } else { resolve(socket) } }) }) if (client.destroyed) { util.destroy(socket.on('error', () => {}), new ClientDestroyedError()) return } client[kConnecting] = false assert(socket) const isH2 = socket.alpnProtocol === 'h2' if (isH2) { if (!h2ExperimentalWarned) { h2ExperimentalWarned = true process.emitWarning('H2 support is experimental, expect them to change at any time.', { code: 'UNDICI-H2' }) } const session = http2.connect(client[kUrl], { createConnection: () => socket, peerMaxConcurrentStreams: client[kHTTP2SessionState].maxConcurrentStreams }) client[kHTTPConnVersion] = 'h2' session[kClient] = client session[kSocket] = socket session.on('error', onHttp2SessionError) session.on('frameError', onHttp2FrameError) session.on('end', onHttp2SessionEnd) session.on('goaway', onHTTP2GoAway) session.on('close', onSocketClose) session.unref() client[kHTTP2Session] = session socket[kHTTP2Session] = session } else { if (!llhttpInstance) { llhttpInstance = await llhttpPromise llhttpPromise = null } socket[kNoRef] = false socket[kWriting] = false socket[kReset] = false socket[kBlocking] = false socket[kParser] = new Parser(client, socket, llhttpInstance) } socket[kCounter] = 0 socket[kMaxRequests] = client[kMaxRequests] socket[kClient] = client socket[kError] = null socket .on('error', onSocketError) .on('readable', onSocketReadable) .on('end', onSocketEnd) .on('close', onSocketClose) client[kSocket] = socket if (channels.connected.hasSubscribers) { channels.connected.publish({ connectParams: { host, hostname, protocol, port, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector], socket }) } client.emit('connect', client[kUrl], [client]) } catch (err) { if (client.destroyed) { return } client[kConnecting] = false if (channels.connectError.hasSubscribers) { channels.connectError.publish({ connectParams: { host, hostname, protocol, port, servername: client[kServerName], localAddress: client[kLocalAddress] }, connector: client[kConnector], error: err }) } if (err.code === 'ERR_TLS_CERT_ALTNAME_INVALID') { assert(client[kRunning] === 0) while (client[kPending] > 0 && client[kQueue][client[kPendingIdx]].servername === client[kServerName]) { const request = client[kQueue][client[kPendingIdx]++] errorRequest(client, request, err) } } else { onError(client, err) } client.emit('connectionError', client[kUrl], [client], err) } resume(client) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
connect
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function emitDrain (client) { client[kNeedDrain] = 0 client.emit('drain', client[kUrl], [client]) }
@param {string|URL} url @param {import('../types/client').Client.Options} options
emitDrain
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function resume (client, sync) { if (client[kResuming] === 2) { return } client[kResuming] = 2 _resume(client, sync) client[kResuming] = 0 if (client[kRunningIdx] > 256) { client[kQueue].splice(0, client[kRunningIdx]) client[kPendingIdx] -= client[kRunningIdx] client[kRunningIdx] = 0 } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
resume
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function _resume (client, sync) { while (true) { if (client.destroyed) { assert(client[kPending] === 0) return } if (client[kClosedResolve] && !client[kSize]) { client[kClosedResolve]() client[kClosedResolve] = null return } const socket = client[kSocket] if (socket && !socket.destroyed && socket.alpnProtocol !== 'h2') { if (client[kSize] === 0) { if (!socket[kNoRef] && socket.unref) { socket.unref() socket[kNoRef] = true } } else if (socket[kNoRef] && socket.ref) { socket.ref() socket[kNoRef] = false } if (client[kSize] === 0) { if (socket[kParser].timeoutType !== TIMEOUT_IDLE) { socket[kParser].setTimeout(client[kKeepAliveTimeoutValue], TIMEOUT_IDLE) } } else if (client[kRunning] > 0 && socket[kParser].statusCode < 200) { if (socket[kParser].timeoutType !== TIMEOUT_HEADERS) { const request = client[kQueue][client[kRunningIdx]] const headersTimeout = request.headersTimeout != null ? request.headersTimeout : client[kHeadersTimeout] socket[kParser].setTimeout(headersTimeout, TIMEOUT_HEADERS) } } } if (client[kBusy]) { client[kNeedDrain] = 2 } else if (client[kNeedDrain] === 2) { if (sync) { client[kNeedDrain] = 1 process.nextTick(emitDrain, client) } else { emitDrain(client) } continue } if (client[kPending] === 0) { return } if (client[kRunning] >= (client[kPipelining] || 1)) { return } const request = client[kQueue][client[kPendingIdx]] if (client[kUrl].protocol === 'https:' && client[kServerName] !== request.servername) { if (client[kRunning] > 0) { return } client[kServerName] = request.servername if (socket && socket.servername !== request.servername) { util.destroy(socket, new InformationalError('servername changed')) return } } if (client[kConnecting]) { return } if (!socket && !client[kHTTP2Session]) { connect(client) return } if (socket.destroyed || socket[kWriting] || socket[kReset] || socket[kBlocking]) { return } if (client[kRunning] > 0 && !request.idempotent) { // Non-idempotent request cannot be retried. // Ensure that no other requests are inflight and // could cause failure. return } if (client[kRunning] > 0 && (request.upgrade || request.method === 'CONNECT')) { // Don't dispatch an upgrade until all preceding requests have completed. // A misbehaving server might upgrade the connection before all pipelined // request has completed. return } if (client[kRunning] > 0 && util.bodyLength(request.body) !== 0 && (util.isStream(request.body) || util.isAsyncIterable(request.body))) { // Request with stream or iterator body can error while other requests // are inflight and indirectly error those as well. // Ensure this doesn't happen by waiting for inflight // to complete before dispatching. // Request with stream or iterator body cannot be retried. // Ensure that no other requests are inflight and // could cause failure. return } if (!request.aborted && write(client, request)) { client[kPendingIdx]++ } else { client[kQueue].splice(client[kPendingIdx], 1) } } }
@param {string|URL} url @param {import('../types/client').Client.Options} options
_resume
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function shouldSendContentLength (method) { return method !== 'GET' && method !== 'HEAD' && method !== 'OPTIONS' && method !== 'TRACE' && method !== 'CONNECT' }
@param {string|URL} url @param {import('../types/client').Client.Options} options
shouldSendContentLength
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function write (client, request) { if (client[kHTTPConnVersion] === 'h2') { writeH2(client, client[kHTTP2Session], request) return } const { body, method, path, host, upgrade, headers, blocking, reset } = request // https://tools.ietf.org/html/rfc7231#section-4.3.1 // https://tools.ietf.org/html/rfc7231#section-4.3.2 // https://tools.ietf.org/html/rfc7231#section-4.3.5 // Sending a payload body on a request that does not // expect it can cause undefined behavior on some // servers and corrupt connection state. Do not // re-use the connection for further requests. const expectsPayload = ( method === 'PUT' || method === 'POST' || method === 'PATCH' ) if (body && typeof body.read === 'function') { // Try to read EOF in order to get length. body.read(0) } const bodyLength = util.bodyLength(body) let contentLength = bodyLength if (contentLength === null) { contentLength = request.contentLength } if (contentLength === 0 && !expectsPayload) { // https://tools.ietf.org/html/rfc7230#section-3.3.2 // A user agent SHOULD NOT send a Content-Length header field when // the request message does not contain a payload body and the method // semantics do not anticipate such a body. contentLength = null } // https://github.com/nodejs/undici/issues/2046 // A user agent may send a Content-Length header with 0 value, this should be allowed. if (shouldSendContentLength(method) && contentLength > 0 && request.contentLength !== null && request.contentLength !== contentLength) { if (client[kStrictContentLength]) { errorRequest(client, request, new RequestContentLengthMismatchError()) return false } process.emitWarning(new RequestContentLengthMismatchError()) } const socket = client[kSocket] try { request.onConnect((err) => { if (request.aborted || request.completed) { return } errorRequest(client, request, err || new RequestAbortedError()) util.destroy(socket, new InformationalError('aborted')) }) } catch (err) { errorRequest(client, request, err) } if (request.aborted) { return false } if (method === 'HEAD') { // https://github.com/mcollina/undici/issues/258 // Close after a HEAD request to interop with misbehaving servers // that may send a body in the response. socket[kReset] = true } if (upgrade || method === 'CONNECT') { // On CONNECT or upgrade, block pipeline from dispatching further // requests on this connection. socket[kReset] = true } if (reset != null) { socket[kReset] = reset } if (client[kMaxRequests] && socket[kCounter]++ >= client[kMaxRequests]) { socket[kReset] = true } if (blocking) { socket[kBlocking] = true } let header = `${method} ${path} HTTP/1.1\r\n` if (typeof host === 'string') { header += `host: ${host}\r\n` } else { header += client[kHostHeader] } if (upgrade) { header += `connection: upgrade\r\nupgrade: ${upgrade}\r\n` } else if (client[kPipelining] && !socket[kReset]) { header += 'connection: keep-alive\r\n' } else { header += 'connection: close\r\n' } if (headers) { header += headers } if (channels.sendHeaders.hasSubscribers) { channels.sendHeaders.publish({ request, headers: header, socket }) } /* istanbul ignore else: assertion */ if (!body || bodyLength === 0) { if (contentLength === 0) { socket.write(`${header}content-length: 0\r\n\r\n`, 'latin1') } else { assert(contentLength === null, 'no body must not have content length') socket.write(`${header}\r\n`, 'latin1') } request.onRequestSent() } else if (util.isBuffer(body)) { assert(contentLength === body.byteLength, 'buffer body must have content length') socket.cork() socket.write(`${header}content-length: ${contentLength}\r\n\r\n`, 'latin1') socket.write(body) socket.uncork() request.onBodySent(body) request.onRequestSent() if (!expectsPayload) { socket[kReset] = true } } else if (util.isBlobLike(body)) { if (typeof body.stream === 'function') { writeIterable({ body: body.stream(), client, request, socket, contentLength, header, expectsPayload }) } else { writeBlob({ body, client, request, socket, contentLength, header, expectsPayload }) } } else if (util.isStream(body)) { writeStream({ body, client, request, socket, contentLength, header, expectsPayload }) } else if (util.isIterable(body)) { writeIterable({ body, client, request, socket, contentLength, header, expectsPayload }) } else { assert(false) } return true }
@param {string|URL} url @param {import('../types/client').Client.Options} options
write
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function deleteCookie (headers, name, attributes) { webidl.argumentLengthCheck(arguments, 2, { header: 'deleteCookie' }) webidl.brandCheck(headers, Headers, { strict: false }) name = webidl.converters.DOMString(name) attributes = webidl.converters.DeleteCookieAttributes(attributes) // Matches behavior of // https://github.com/denoland/deno_std/blob/63827b16330b82489a04614027c33b7904e08be5/http/cookie.ts#L278 setCookie(headers, { name, value: '', expires: new Date(0), ...attributes }) }
@param {Headers} headers @param {Cookie} cookie @returns {void}
deleteCookie
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getSetCookies (headers) { webidl.argumentLengthCheck(arguments, 1, { header: 'getSetCookies' }) webidl.brandCheck(headers, Headers, { strict: false }) const cookies = getHeadersList(headers).cookies if (!cookies) { return [] } // In older versions of undici, cookies is a list of name:value. return cookies.map((pair) => parseSetCookie(Array.isArray(pair) ? pair[1] : pair)) }
@param {Headers} headers @param {Cookie} cookie @returns {void}
getSetCookies
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function setCookie (headers, cookie) { webidl.argumentLengthCheck(arguments, 2, { header: 'setCookie' }) webidl.brandCheck(headers, Headers, { strict: false }) cookie = webidl.converters.Cookie(cookie) const str = stringify(cookie) if (str) { headers.append('Set-Cookie', stringify(cookie)) } }
@param {Headers} headers @param {Cookie} cookie @returns {void}
setCookie
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function parseSetCookie (header) { // 1. If the set-cookie-string contains a %x00-08 / %x0A-1F / %x7F // character (CTL characters excluding HTAB): Abort these steps and // ignore the set-cookie-string entirely. if (isCTLExcludingHtab(header)) { return null } let nameValuePair = '' let unparsedAttributes = '' let name = '' let value = '' // 2. If the set-cookie-string contains a %x3B (";") character: if (header.includes(';')) { // 1. The name-value-pair string consists of the characters up to, // but not including, the first %x3B (";"), and the unparsed- // attributes consist of the remainder of the set-cookie-string // (including the %x3B (";") in question). const position = { position: 0 } nameValuePair = collectASequenceOfCodePointsFast(';', header, position) unparsedAttributes = header.slice(position.position) } else { // Otherwise: // 1. The name-value-pair string consists of all the characters // contained in the set-cookie-string, and the unparsed- // attributes is the empty string. nameValuePair = header } // 3. If the name-value-pair string lacks a %x3D ("=") character, then // the name string is empty, and the value string is the value of // name-value-pair. if (!nameValuePair.includes('=')) { value = nameValuePair } else { // Otherwise, the name string consists of the characters up to, but // not including, the first %x3D ("=") character, and the (possibly // empty) value string consists of the characters after the first // %x3D ("=") character. const position = { position: 0 } name = collectASequenceOfCodePointsFast( '=', nameValuePair, position ) value = nameValuePair.slice(position.position + 1) } // 4. Remove any leading or trailing WSP characters from the name // string and the value string. name = name.trim() value = value.trim() // 5. If the sum of the lengths of the name string and the value string // is more than 4096 octets, abort these steps and ignore the set- // cookie-string entirely. if (name.length + value.length > maxNameValuePairSize) { return null } // 6. The cookie-name is the name string, and the cookie-value is the // value string. return { name, value, ...parseUnparsedAttributes(unparsedAttributes) } }
@description Parses the field-value attributes of a set-cookie header string. @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4 @param {string} header @returns if the header is invalid, null will be returned
parseSetCookie
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function parseUnparsedAttributes (unparsedAttributes, cookieAttributeList = {}) { // 1. If the unparsed-attributes string is empty, skip the rest of // these steps. if (unparsedAttributes.length === 0) { return cookieAttributeList } // 2. Discard the first character of the unparsed-attributes (which // will be a %x3B (";") character). assert(unparsedAttributes[0] === ';') unparsedAttributes = unparsedAttributes.slice(1) let cookieAv = '' // 3. If the remaining unparsed-attributes contains a %x3B (";") // character: if (unparsedAttributes.includes(';')) { // 1. Consume the characters of the unparsed-attributes up to, but // not including, the first %x3B (";") character. cookieAv = collectASequenceOfCodePointsFast( ';', unparsedAttributes, { position: 0 } ) unparsedAttributes = unparsedAttributes.slice(cookieAv.length) } else { // Otherwise: // 1. Consume the remainder of the unparsed-attributes. cookieAv = unparsedAttributes unparsedAttributes = '' } // Let the cookie-av string be the characters consumed in this step. let attributeName = '' let attributeValue = '' // 4. If the cookie-av string contains a %x3D ("=") character: if (cookieAv.includes('=')) { // 1. The (possibly empty) attribute-name string consists of the // characters up to, but not including, the first %x3D ("=") // character, and the (possibly empty) attribute-value string // consists of the characters after the first %x3D ("=") // character. const position = { position: 0 } attributeName = collectASequenceOfCodePointsFast( '=', cookieAv, position ) attributeValue = cookieAv.slice(position.position + 1) } else { // Otherwise: // 1. The attribute-name string consists of the entire cookie-av // string, and the attribute-value string is empty. attributeName = cookieAv } // 5. Remove any leading or trailing WSP characters from the attribute- // name string and the attribute-value string. attributeName = attributeName.trim() attributeValue = attributeValue.trim() // 6. If the attribute-value is longer than 1024 octets, ignore the // cookie-av string and return to Step 1 of this algorithm. if (attributeValue.length > maxAttributeValueSize) { return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) } // 7. Process the attribute-name and attribute-value according to the // requirements in the following subsections. (Notice that // attributes with unrecognized attribute-names are ignored.) const attributeNameLowercase = attributeName.toLowerCase() // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.1 // If the attribute-name case-insensitively matches the string // "Expires", the user agent MUST process the cookie-av as follows. if (attributeNameLowercase === 'expires') { // 1. Let the expiry-time be the result of parsing the attribute-value // as cookie-date (see Section 5.1.1). const expiryTime = new Date(attributeValue) // 2. If the attribute-value failed to parse as a cookie date, ignore // the cookie-av. cookieAttributeList.expires = expiryTime } else if (attributeNameLowercase === 'max-age') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.2 // If the attribute-name case-insensitively matches the string "Max- // Age", the user agent MUST process the cookie-av as follows. // 1. If the first character of the attribute-value is not a DIGIT or a // "-" character, ignore the cookie-av. const charCode = attributeValue.charCodeAt(0) if ((charCode < 48 || charCode > 57) && attributeValue[0] !== '-') { return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) } // 2. If the remainder of attribute-value contains a non-DIGIT // character, ignore the cookie-av. if (!/^\d+$/.test(attributeValue)) { return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) } // 3. Let delta-seconds be the attribute-value converted to an integer. const deltaSeconds = Number(attributeValue) // 4. Let cookie-age-limit be the maximum age of the cookie (which // SHOULD be 400 days or less, see Section 4.1.2.2). // 5. Set delta-seconds to the smaller of its present value and cookie- // age-limit. // deltaSeconds = Math.min(deltaSeconds * 1000, maxExpiresMs) // 6. If delta-seconds is less than or equal to zero (0), let expiry- // time be the earliest representable date and time. Otherwise, let // the expiry-time be the current date and time plus delta-seconds // seconds. // const expiryTime = deltaSeconds <= 0 ? Date.now() : Date.now() + deltaSeconds // 7. Append an attribute to the cookie-attribute-list with an // attribute-name of Max-Age and an attribute-value of expiry-time. cookieAttributeList.maxAge = deltaSeconds } else if (attributeNameLowercase === 'domain') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.3 // If the attribute-name case-insensitively matches the string "Domain", // the user agent MUST process the cookie-av as follows. // 1. Let cookie-domain be the attribute-value. let cookieDomain = attributeValue // 2. If cookie-domain starts with %x2E ("."), let cookie-domain be // cookie-domain without its leading %x2E ("."). if (cookieDomain[0] === '.') { cookieDomain = cookieDomain.slice(1) } // 3. Convert the cookie-domain to lower case. cookieDomain = cookieDomain.toLowerCase() // 4. Append an attribute to the cookie-attribute-list with an // attribute-name of Domain and an attribute-value of cookie-domain. cookieAttributeList.domain = cookieDomain } else if (attributeNameLowercase === 'path') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.4 // If the attribute-name case-insensitively matches the string "Path", // the user agent MUST process the cookie-av as follows. // 1. If the attribute-value is empty or if the first character of the // attribute-value is not %x2F ("/"): let cookiePath = '' if (attributeValue.length === 0 || attributeValue[0] !== '/') { // 1. Let cookie-path be the default-path. cookiePath = '/' } else { // Otherwise: // 1. Let cookie-path be the attribute-value. cookiePath = attributeValue } // 2. Append an attribute to the cookie-attribute-list with an // attribute-name of Path and an attribute-value of cookie-path. cookieAttributeList.path = cookiePath } else if (attributeNameLowercase === 'secure') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.5 // If the attribute-name case-insensitively matches the string "Secure", // the user agent MUST append an attribute to the cookie-attribute-list // with an attribute-name of Secure and an empty attribute-value. cookieAttributeList.secure = true } else if (attributeNameLowercase === 'httponly') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.6 // If the attribute-name case-insensitively matches the string // "HttpOnly", the user agent MUST append an attribute to the cookie- // attribute-list with an attribute-name of HttpOnly and an empty // attribute-value. cookieAttributeList.httpOnly = true } else if (attributeNameLowercase === 'samesite') { // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4.7 // If the attribute-name case-insensitively matches the string // "SameSite", the user agent MUST process the cookie-av as follows: // 1. Let enforcement be "Default". let enforcement = 'Default' const attributeValueLowercase = attributeValue.toLowerCase() // 2. If cookie-av's attribute-value is a case-insensitive match for // "None", set enforcement to "None". if (attributeValueLowercase.includes('none')) { enforcement = 'None' } // 3. If cookie-av's attribute-value is a case-insensitive match for // "Strict", set enforcement to "Strict". if (attributeValueLowercase.includes('strict')) { enforcement = 'Strict' } // 4. If cookie-av's attribute-value is a case-insensitive match for // "Lax", set enforcement to "Lax". if (attributeValueLowercase.includes('lax')) { enforcement = 'Lax' } // 5. Append an attribute to the cookie-attribute-list with an // attribute-name of "SameSite" and an attribute-value of // enforcement. cookieAttributeList.sameSite = enforcement } else { cookieAttributeList.unparsed ??= [] cookieAttributeList.unparsed.push(`${attributeName}=${attributeValue}`) } // 8. Return to Step 1 of this algorithm. return parseUnparsedAttributes(unparsedAttributes, cookieAttributeList) }
Parses the remaining attributes of a set-cookie header @see https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis#section-5.4 @param {string} unparsedAttributes @param {[Object.<string, unknown>]={}} cookieAttributeList
parseUnparsedAttributes
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isCTLExcludingHtab (value) { if (value.length === 0) { return false } for (const char of value) { const code = char.charCodeAt(0) if ( (code >= 0x00 || code <= 0x08) || (code >= 0x0A || code <= 0x1F) || code === 0x7F ) { return false } } }
CHAR = <any US-ASCII character (octets 0 - 127)> token = 1*<any CHAR except CTLs or separators> separators = "(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\" | <"> | "/" | "[" | "]" | "?" | "=" | "{" | "}" | SP | HT @param {string} name
isCTLExcludingHtab
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateCookieName (name) { for (const char of name) { const code = char.charCodeAt(0) if ( (code <= 0x20 || code > 0x7F) || char === '(' || char === ')' || char === '>' || char === '<' || char === '@' || char === ',' || char === ';' || char === ':' || char === '\\' || char === '"' || char === '/' || char === '[' || char === ']' || char === '?' || char === '=' || char === '{' || char === '}' ) { throw new Error('Invalid cookie name') } } }
path-value = <any CHAR except CTLs or ";"> @param {string} path
validateCookieName
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateCookieValue (value) { for (const char of value) { const code = char.charCodeAt(0) if ( code < 0x21 || // exclude CTLs (0-31) code === 0x22 || code === 0x2C || code === 0x3B || code === 0x5C || code > 0x7E // non-ascii ) { throw new Error('Invalid header value') } } }
I have no idea why these values aren't allowed to be honest, but Deno tests these. - Khafra @param {string} domain
validateCookieValue
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateCookiePath (path) { for (const char of path) { const code = char.charCodeAt(0) if (code < 0x21 || char === ';') { throw new Error('Invalid cookie path') } } }
I have no idea why these values aren't allowed to be honest, but Deno tests these. - Khafra @param {string} domain
validateCookiePath
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateCookieDomain (domain) { if ( domain.startsWith('-') || domain.endsWith('.') || domain.endsWith('-') ) { throw new Error('Invalid cookie domain') } }
I have no idea why these values aren't allowed to be honest, but Deno tests these. - Khafra @param {string} domain
validateCookieDomain
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function toIMFDate (date) { if (typeof date === 'number') { date = new Date(date) } const days = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ] const months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] const dayName = days[date.getUTCDay()] const day = date.getUTCDate().toString().padStart(2, '0') const month = months[date.getUTCMonth()] const year = date.getUTCFullYear() const hour = date.getUTCHours().toString().padStart(2, '0') const minute = date.getUTCMinutes().toString().padStart(2, '0') const second = date.getUTCSeconds().toString().padStart(2, '0') return `${dayName}, ${day} ${month} ${year} ${hour}:${minute}:${second} GMT` }
@see https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1 @param {import('./index').Cookie} cookie
toIMFDate
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateCookieMaxAge (maxAge) { if (maxAge < 0) { throw new Error('Invalid cookie max-age') } }
@see https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1 @param {import('./index').Cookie} cookie
validateCookieMaxAge
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function stringify (cookie) { if (cookie.name.length === 0) { return null } validateCookieName(cookie.name) validateCookieValue(cookie.value) const out = [`${cookie.name}=${cookie.value}`] // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-prefixes-00#section-3.1 // https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-cookie-prefixes-00#section-3.2 if (cookie.name.startsWith('__Secure-')) { cookie.secure = true } if (cookie.name.startsWith('__Host-')) { cookie.secure = true cookie.domain = null cookie.path = '/' } if (cookie.secure) { out.push('Secure') } if (cookie.httpOnly) { out.push('HttpOnly') } if (typeof cookie.maxAge === 'number') { validateCookieMaxAge(cookie.maxAge) out.push(`Max-Age=${cookie.maxAge}`) } if (cookie.domain) { validateCookieDomain(cookie.domain) out.push(`Domain=${cookie.domain}`) } if (cookie.path) { validateCookiePath(cookie.path) out.push(`Path=${cookie.path}`) } if (cookie.expires && cookie.expires.toString() !== 'Invalid Date') { out.push(`Expires=${toIMFDate(cookie.expires)}`) } if (cookie.sameSite) { out.push(`SameSite=${cookie.sameSite}`) } for (const part of cookie.unparsed) { if (!part.includes('=')) { throw new Error('Invalid unparsed') } const [key, ...value] = part.split('=') out.push(`${key.trim()}=${value.join('=')}`) } return out.join('; ') }
@see https://www.rfc-editor.org/rfc/rfc6265#section-4.1.1 @param {import('./index').Cookie} cookie
stringify
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
constructor (origin, { path, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, throwOnError, expectContinue }, handler) { if (typeof path !== 'string') { throw new InvalidArgumentError('path must be a string') } else if ( path[0] !== '/' && !(path.startsWith('http://') || path.startsWith('https://')) && method !== 'CONNECT' ) { throw new InvalidArgumentError('path must be an absolute URL or start with a slash') } else if (invalidPathRegex.exec(path) !== null) { throw new InvalidArgumentError('invalid request path') } if (typeof method !== 'string') { throw new InvalidArgumentError('method must be a string') } else if (tokenRegExp.exec(method) === null) { throw new InvalidArgumentError('invalid request method') } if (upgrade && typeof upgrade !== 'string') { throw new InvalidArgumentError('upgrade must be a string') } if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) { throw new InvalidArgumentError('invalid headersTimeout') } if (bodyTimeout != null && (!Number.isFinite(bodyTimeout) || bodyTimeout < 0)) { throw new InvalidArgumentError('invalid bodyTimeout') } if (reset != null && typeof reset !== 'boolean') { throw new InvalidArgumentError('invalid reset') } if (expectContinue != null && typeof expectContinue !== 'boolean') { throw new InvalidArgumentError('invalid expectContinue') } this.headersTimeout = headersTimeout this.bodyTimeout = bodyTimeout this.throwOnError = throwOnError === true this.method = method this.abort = null if (body == null) { this.body = null } else if (util.isStream(body)) { this.body = body const rState = this.body._readableState if (!rState || !rState.autoDestroy) { this.endHandler = function autoDestroy () { util.destroy(this) } this.body.on('end', this.endHandler) } this.errorHandler = err => { if (this.abort) { this.abort(err) } else { this.error = err } } this.body.on('error', this.errorHandler) } else if (util.isBuffer(body)) { this.body = body.byteLength ? body : null } else if (ArrayBuffer.isView(body)) { this.body = body.buffer.byteLength ? Buffer.from(body.buffer, body.byteOffset, body.byteLength) : null } else if (body instanceof ArrayBuffer) { this.body = body.byteLength ? Buffer.from(body) : null } else if (typeof body === 'string') { this.body = body.length ? Buffer.from(body) : null } else if (util.isFormDataLike(body) || util.isIterable(body) || util.isBlobLike(body)) { this.body = body } else { throw new InvalidArgumentError('body must be a string, a Buffer, a Readable stream, an iterable, or an async iterable') } this.completed = false this.aborted = false this.upgrade = upgrade || null this.path = query ? util.buildURL(path, query) : path this.origin = origin this.idempotent = idempotent == null ? method === 'HEAD' || method === 'GET' : idempotent this.blocking = blocking == null ? false : blocking this.reset = reset == null ? null : reset this.host = null this.contentLength = null this.contentType = null this.headers = '' // Only for H2 this.expectContinue = expectContinue != null ? expectContinue : false if (Array.isArray(headers)) { if (headers.length % 2 !== 0) { throw new InvalidArgumentError('headers array must be even') } for (let i = 0; i < headers.length; i += 2) { processHeader(this, headers[i], headers[i + 1]) } } else if (headers && typeof headers === 'object') { const keys = Object.keys(headers) for (let i = 0; i < keys.length; i++) { const key = keys[i] processHeader(this, key, headers[key]) } } else if (headers != null) { throw new InvalidArgumentError('headers must be an object or an array') } if (util.isFormDataLike(this.body)) { if (util.nodeMajor < 16 || (util.nodeMajor === 16 && util.nodeMinor < 8)) { throw new InvalidArgumentError('Form-Data bodies are only supported in node v16.8 and newer.') } if (!extractBody) { extractBody = (__nccwpck_require__(8544).extractBody) } const [bodyStream, contentType] = extractBody(body) if (this.contentType == null) { this.contentType = contentType this.headers += `content-type: ${contentType}\r\n` } this.body = bodyStream.stream this.contentLength = bodyStream.length } else if (util.isBlobLike(body) && this.contentType == null && body.type) { this.contentType = body.type this.headers += `content-type: ${body.type}\r\n` } util.validateHandler(handler, method, upgrade) this.servername = util.getServerName(this.host) this[kHandler] = handler if (channels.create.hasSubscribers) { channels.create.publish({ request: this }) } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
constructor
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onBodySent (chunk) { if (this[kHandler].onBodySent) { try { return this[kHandler].onBodySent(chunk) } catch (err) { this.abort(err) } } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onBodySent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onRequestSent () { if (channels.bodySent.hasSubscribers) { channels.bodySent.publish({ request: this }) } if (this[kHandler].onRequestSent) { try { return this[kHandler].onRequestSent() } catch (err) { this.abort(err) } } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onRequestSent
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onConnect (abort) { assert(!this.aborted) assert(!this.completed) if (this.error) { abort(this.error) } else { this.abort = abort return this[kHandler].onConnect(abort) } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onConnect
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onHeaders (statusCode, headers, resume, statusText) { assert(!this.aborted) assert(!this.completed) if (channels.headers.hasSubscribers) { channels.headers.publish({ request: this, response: { statusCode, headers, statusText } }) } try { return this[kHandler].onHeaders(statusCode, headers, resume, statusText) } catch (err) { this.abort(err) } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onHeaders
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onData (chunk) { assert(!this.aborted) assert(!this.completed) try { return this[kHandler].onData(chunk) } catch (err) { this.abort(err) return false } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onData
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onUpgrade (statusCode, headers, socket) { assert(!this.aborted) assert(!this.completed) return this[kHandler].onUpgrade(statusCode, headers, socket) }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onUpgrade
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onComplete (trailers) { this.onFinally() assert(!this.aborted) this.completed = true if (channels.trailers.hasSubscribers) { channels.trailers.publish({ request: this, trailers }) } try { return this[kHandler].onComplete(trailers) } catch (err) { // TODO (fix): This might be a bad idea? this.onError(err) } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onComplete
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onError (error) { this.onFinally() if (channels.error.hasSubscribers) { channels.error.publish({ request: this, error }) } if (this.aborted) { return } this.aborted = true return this[kHandler].onError(error) }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onError
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
onFinally () { if (this.errorHandler) { this.body.off('error', this.errorHandler) this.errorHandler = null } if (this.endHandler) { this.body.off('end', this.endHandler) this.endHandler = null } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
onFinally
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
addHeader (key, value) { processHeader(this, key, value) return this }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
addHeader
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function processHeaderValue (key, val, skipAppend) { if (val && typeof val === 'object') { throw new InvalidArgumentError(`invalid ${key} header`) } val = val != null ? `${val}` : '' if (headerCharRegex.exec(val) !== null) { throw new InvalidArgumentError(`invalid ${key} header`) } return skipAppend ? val : `${key}: ${val}\r\n` }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
processHeaderValue
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function processHeader (request, key, val, skipAppend = false) { if (val && (typeof val === 'object' && !Array.isArray(val))) { throw new InvalidArgumentError(`invalid ${key} header`) } else if (val === undefined) { return } if ( request.host === null && key.length === 4 && key.toLowerCase() === 'host' ) { if (headerCharRegex.exec(val) !== null) { throw new InvalidArgumentError(`invalid ${key} header`) } // Consumed by Client request.host = val } else if ( request.contentLength === null && key.length === 14 && key.toLowerCase() === 'content-length' ) { request.contentLength = parseInt(val, 10) if (!Number.isFinite(request.contentLength)) { throw new InvalidArgumentError('invalid content-length header') } } else if ( request.contentType === null && key.length === 12 && key.toLowerCase() === 'content-type' ) { request.contentType = val if (skipAppend) request.headers[key] = processHeaderValue(key, val, skipAppend) else request.headers += processHeaderValue(key, val) } else if ( key.length === 17 && key.toLowerCase() === 'transfer-encoding' ) { throw new InvalidArgumentError('invalid transfer-encoding header') } else if ( key.length === 10 && key.toLowerCase() === 'connection' ) { const value = typeof val === 'string' ? val.toLowerCase() : null if (value !== 'close' && value !== 'keep-alive') { throw new InvalidArgumentError('invalid connection header') } else if (value === 'close') { request.reset = true } } else if ( key.length === 10 && key.toLowerCase() === 'keep-alive' ) { throw new InvalidArgumentError('invalid keep-alive header') } else if ( key.length === 7 && key.toLowerCase() === 'upgrade' ) { throw new InvalidArgumentError('invalid upgrade header') } else if ( key.length === 6 && key.toLowerCase() === 'expect' ) { throw new NotSupportedError('expect header not supported') } else if (tokenRegExp.exec(key) === null) { throw new InvalidArgumentError('invalid header key') } else { if (Array.isArray(val)) { for (let i = 0; i < val.length; i++) { if (skipAppend) { if (request.headers[key]) request.headers[key] += `,${processHeaderValue(key, val[i], skipAppend)}` else request.headers[key] = processHeaderValue(key, val[i], skipAppend) } else { request.headers += processHeaderValue(key, val[i]) } } } else { if (skipAppend) request.headers[key] = processHeaderValue(key, val, skipAppend) else request.headers += processHeaderValue(key, val) } } }
Matches if val contains an invalid field-vchar field-value = *( field-content / obs-fold ) field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] field-vchar = VCHAR / obs-text
processHeader
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isDestroyed (stream) { return !stream || !!(stream.destroyed || stream[kDestroyed]) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isDestroyed
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isReadableAborted (stream) { const state = stream && stream._readableState return isDestroyed(stream) && state && !state.endEmitted }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isReadableAborted
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function destroy (stream, err) { if (stream == null || !isStream(stream) || isDestroyed(stream)) { return } if (typeof stream.destroy === 'function') { if (Object.getPrototypeOf(stream).constructor === IncomingMessage) { // See: https://github.com/nodejs/node/pull/38505/files stream.socket = null } stream.destroy(err) } else if (err) { process.nextTick((stream, err) => { stream.emit('error', err) }, stream, err) } if (stream.destroyed !== true) { stream[kDestroyed] = true } }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
destroy
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function parseKeepAliveTimeout (val) { const m = val.toString().match(KEEPALIVE_TIMEOUT_EXPR) return m ? parseInt(m[1], 10) * 1000 : null }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
parseKeepAliveTimeout
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function headerNameToString (value) { return headerNameLowerCasedRecord[value] || value.toLowerCase() }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
headerNameToString
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function parseHeaders (headers, obj = {}) { // For H2 support if (!Array.isArray(headers)) return headers for (let i = 0; i < headers.length; i += 2) { const key = headers[i].toString().toLowerCase() let val = obj[key] if (!val) { if (Array.isArray(headers[i + 1])) { obj[key] = headers[i + 1].map(x => x.toString('utf8')) } else { obj[key] = headers[i + 1].toString('utf8') } } else { if (!Array.isArray(val)) { val = [val] obj[key] = val } val.push(headers[i + 1].toString('utf8')) } } // See https://github.com/nodejs/node/pull/46528 if ('content-length' in obj && 'content-disposition' in obj) { obj['content-disposition'] = Buffer.from(obj['content-disposition']).toString('latin1') } return obj }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
parseHeaders
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function parseRawHeaders (headers) { const ret = [] let hasContentLength = false let contentDispositionIdx = -1 for (let n = 0; n < headers.length; n += 2) { const key = headers[n + 0].toString() const val = headers[n + 1].toString('utf8') if (key.length === 14 && (key === 'content-length' || key.toLowerCase() === 'content-length')) { ret.push(key, val) hasContentLength = true } else if (key.length === 19 && (key === 'content-disposition' || key.toLowerCase() === 'content-disposition')) { contentDispositionIdx = ret.push(key, val) - 1 } else { ret.push(key, val) } } // See https://github.com/nodejs/node/pull/46528 if (hasContentLength && contentDispositionIdx !== -1) { ret[contentDispositionIdx] = Buffer.from(ret[contentDispositionIdx]).toString('latin1') } return ret }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
parseRawHeaders
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isBuffer (buffer) { // See, https://github.com/mcollina/undici/pull/319 return buffer instanceof Uint8Array || Buffer.isBuffer(buffer) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isBuffer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function validateHandler (handler, method, upgrade) { if (!handler || typeof handler !== 'object') { throw new InvalidArgumentError('handler must be an object') } if (typeof handler.onConnect !== 'function') { throw new InvalidArgumentError('invalid onConnect method') } if (typeof handler.onError !== 'function') { throw new InvalidArgumentError('invalid onError method') } if (typeof handler.onBodySent !== 'function' && handler.onBodySent !== undefined) { throw new InvalidArgumentError('invalid onBodySent method') } if (upgrade || method === 'CONNECT') { if (typeof handler.onUpgrade !== 'function') { throw new InvalidArgumentError('invalid onUpgrade method') } } else { if (typeof handler.onHeaders !== 'function') { throw new InvalidArgumentError('invalid onHeaders method') } if (typeof handler.onData !== 'function') { throw new InvalidArgumentError('invalid onData method') } if (typeof handler.onComplete !== 'function') { throw new InvalidArgumentError('invalid onComplete method') } } }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
validateHandler
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isDisturbed (body) { return !!(body && ( stream.isDisturbed ? stream.isDisturbed(body) || body[kBodyUsed] // TODO (fix): Why is body[kBodyUsed] needed? : body[kBodyUsed] || body.readableDidRead || (body._readableState && body._readableState.dataEmitted) || isReadableAborted(body) )) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isDisturbed
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isErrored (body) { return !!(body && ( stream.isErrored ? stream.isErrored(body) : /state: 'errored'/.test(nodeUtil.inspect(body) ))) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isErrored
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isReadable (body) { return !!(body && ( stream.isReadable ? stream.isReadable(body) : /state: 'readable'/.test(nodeUtil.inspect(body) ))) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
isReadable
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function getSocketInfo (socket) { return { localAddress: socket.localAddress, localPort: socket.localPort, remoteAddress: socket.remoteAddress, remotePort: socket.remotePort, remoteFamily: socket.remoteFamily, timeout: socket.timeout, bytesWritten: socket.bytesWritten, bytesRead: socket.bytesRead } }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
getSocketInfo
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async function * convertIterableToBuffer (iterable) { for await (const chunk of iterable) { yield Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk) } }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
convertIterableToBuffer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function ReadableStreamFrom (iterable) { if (!ReadableStream) { ReadableStream = (__nccwpck_require__(3774).ReadableStream) } if (ReadableStream.from) { return ReadableStream.from(convertIterableToBuffer(iterable)) } let iterator return new ReadableStream( { async start () { iterator = iterable[Symbol.asyncIterator]() }, async pull (controller) { const { done, value } = await iterator.next() if (done) { queueMicrotask(() => { controller.close() }) } else { const buf = Buffer.isBuffer(value) ? value : Buffer.from(value) controller.enqueue(new Uint8Array(buf)) } return controller.desiredSize > 0 }, async cancel (reason) { await iterator.return() } }, 0 ) }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
ReadableStreamFrom
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async start () { iterator = iterable[Symbol.asyncIterator]() }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
start
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
async pull (controller) { const { done, value } = await iterator.next() if (done) { queueMicrotask(() => { controller.close() }) } else { const buf = Buffer.isBuffer(value) ? value : Buffer.from(value) controller.enqueue(new Uint8Array(buf)) } return controller.desiredSize > 0 }
Retrieves a header name and returns its lowercase value. @param {string | Buffer} value Header name @returns {string}
pull
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function mixinBody (prototype) { Object.assign(prototype.prototype, bodyMixinMethods(prototype)) }
@see https://fetch.spec.whatwg.org/#concept-body-consume-body @param {Response|Request} object @param {(value: unknown) => unknown} convertBytesToJSValue @param {Response|Request} instance
mixinBody
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
successSteps = (data) => { try { promise.resolve(convertBytesToJSValue(data)) } catch (e) { errorSteps(e) } }
@see https://encoding.spec.whatwg.org/#utf-8-decode @param {Buffer} buffer
successSteps
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
successSteps = (data) => { try { promise.resolve(convertBytesToJSValue(data)) } catch (e) { errorSteps(e) } }
@see https://encoding.spec.whatwg.org/#utf-8-decode @param {Buffer} buffer
successSteps
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function URLSerializer (url, excludeFragment = false) { if (!excludeFragment) { return url.href } const href = url.href const hashLength = url.hash.length return hashLength === 0 ? href : href.substring(0, href.length - hashLength) }
A faster collectASequenceOfCodePoints that only works when comparing a single character. @param {string} char @param {string} input @param {{ position: number }} position
URLSerializer
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function collectAnHTTPQuotedString (input, position, extractValue) { // 1. Let positionStart be position. const positionStart = position.position // 2. Let value be the empty string. let value = '' // 3. Assert: the code point at position within input // is U+0022 ("). assert(input[position.position] === '"') // 4. Advance position by 1. position.position++ // 5. While true: while (true) { // 1. Append the result of collecting a sequence of code points // that are not U+0022 (") or U+005C (\) from input, given // position, to value. value += collectASequenceOfCodePoints( (char) => char !== '"' && char !== '\\', input, position ) // 2. If position is past the end of input, then break. if (position.position >= input.length) { break } // 3. Let quoteOrBackslash be the code point at position within // input. const quoteOrBackslash = input[position.position] // 4. Advance position by 1. position.position++ // 5. If quoteOrBackslash is U+005C (\), then: if (quoteOrBackslash === '\\') { // 1. If position is past the end of input, then append // U+005C (\) to value and break. if (position.position >= input.length) { value += '\\' break } // 2. Append the code point at position within input to value. value += input[position.position] // 3. Advance position by 1. position.position++ // 6. Otherwise: } else { // 1. Assert: quoteOrBackslash is U+0022 ("). assert(quoteOrBackslash === '"') // 2. Break. break } } // 6. If the extract-value flag is set, then return value. if (extractValue) { return value } // 7. Return the code points from positionStart to position, // inclusive, within input. return input.slice(positionStart, position.position) }
@param {string} input @param {{ position: number }} position @param {boolean?} extractValue
collectAnHTTPQuotedString
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
entries () { webidl.brandCheck(this, FormData) return makeIterator( () => this[kState].map(pair => [pair.name, pair.value]), 'FormData', 'key+value' ) }
@param {(value: string, key: string, self: FormData) => void} callbackFn @param {unknown} thisArg
entries
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
keys () { webidl.brandCheck(this, FormData) return makeIterator( () => this[kState].map(pair => [pair.name, pair.value]), 'FormData', 'key' ) }
@see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#create-an-entry @param {string} name @param {string|Blob} value @param {?string} filename @returns
keys
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
values () { webidl.brandCheck(this, FormData) return makeIterator( () => this[kState].map(pair => [pair.name, pair.value]), 'FormData', 'value' ) }
@see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#create-an-entry @param {string} name @param {string|Blob} value @param {?string} filename @returns
values
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
forEach (callbackFn, thisArg = globalThis) { webidl.brandCheck(this, FormData) webidl.argumentLengthCheck(arguments, 1, { header: 'FormData.forEach' }) if (typeof callbackFn !== 'function') { throw new TypeError( "Failed to execute 'forEach' on 'FormData': parameter 1 is not of type 'Function'." ) } for (const [key, value] of this) { callbackFn.apply(thisArg, [value, key, this]) } }
@see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#create-an-entry @param {string} name @param {string|Blob} value @param {?string} filename @returns
forEach
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT
function isHTTPWhiteSpaceCharCode (code) { return code === 0x00a || code === 0x00d || code === 0x009 || code === 0x020 }
@see https://fetch.spec.whatwg.org/#concept-header-value-normalize @param {string} potentialValue
isHTTPWhiteSpaceCharCode
javascript
vercel/next.js
.github/actions/next-integration-stat/dist/index.js
https://github.com/vercel/next.js/blob/master/.github/actions/next-integration-stat/dist/index.js
MIT