@web-std/fetch
Advanced tools
+19
-12
@@ -9,2 +9,3 @@ 'use strict'; | ||
| const dataUriToBuffer = require('data-uri-to-buffer'); | ||
| const buffer = require('buffer'); | ||
| const Stream = require('stream'); | ||
@@ -2020,3 +2021,3 @@ const util = require('util'); | ||
| function fixResponseChunkedTransferBadEnding(request, errorCallback) { | ||
| const LAST_CHUNK = Buffer.from('0\r\n\r\n'); | ||
| const LAST_CHUNK = buffer.Buffer.from('0\r\n\r\n'); | ||
@@ -2043,16 +2044,11 @@ let isChunkedTransfer = false; | ||
| socket.prependListener('close', onSocketClose); | ||
| /** @param {Buffer} buf */ | ||
| const onData = buf => { | ||
| properLastChunkReceived = buffer.Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; | ||
| request.on('abort', () => { | ||
| socket.removeListener('close', onSocketClose); | ||
| }); | ||
| socket.on('data', buf => { | ||
| properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; | ||
| // Sometimes final 0-length chunk and end of message code are in separate packets | ||
| if (!properLastChunkReceived && previousChunk) { | ||
| properLastChunkReceived = ( | ||
| Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && | ||
| Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0 | ||
| buffer.Buffer.compare(previousChunk.slice(-3), LAST_CHUNK.slice(0, 3)) === 0 && | ||
| buffer.Buffer.compare(buf.slice(-2), LAST_CHUNK.slice(3)) === 0 | ||
| ); | ||
@@ -2062,3 +2058,14 @@ } | ||
| previousChunk = buf; | ||
| }); | ||
| }; | ||
| socket.prependListener('close', onSocketClose); | ||
| socket.on('data', onData); | ||
| const removeSocketListeners = () => { | ||
| socket.removeListener('close', onSocketClose); | ||
| socket.removeListener('data', onData); | ||
| }; | ||
| request.on('close', removeSocketListeners); | ||
| request.on('abort', removeSocketListeners); | ||
| }); | ||
@@ -2065,0 +2072,0 @@ } |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.js"],"names":[],"mappings":";;;;;;;AA+BA;;;;;;GAMG;AACH,2BAJa,MAAM,GAAG,GAAG,GAAG,OAAO,cAAc,EAAE,OAAO,sFAE7C,QAAQ,OAAO,eAAe,EAAE,OAAO,CAAC,CA0RpD"} | ||
| {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/fetch.js"],"names":[],"mappings":";;;;;;;AAgCA;;;;;;GAMG;AACH,2BAJa,MAAM,GAAG,GAAG,GAAG,OAAO,cAAc,EAAE,OAAO,sFAE7C,QAAQ,OAAO,eAAe,EAAE,OAAO,CAAC,CA0RpD"} |
+1
-1
| { | ||
| "name": "@web-std/fetch", | ||
| "version": "4.2.0", | ||
| "version": "4.2.1", | ||
| "description": "Web API compatible fetch implementation", | ||
@@ -5,0 +5,0 @@ "main": "./dist/lib.node.cjs", |
+15
-8
@@ -15,2 +15,3 @@ /** | ||
| import dataUriToBuffer from 'data-uri-to-buffer'; | ||
| import {Buffer} from 'buffer'; | ||
@@ -350,9 +351,4 @@ import {writeToStream, fromAsyncIterable} from './body.js'; | ||
| socket.prependListener('close', onSocketClose); | ||
| request.on('abort', () => { | ||
| socket.removeListener('close', onSocketClose); | ||
| }); | ||
| socket.on('data', buf => { | ||
| /** @param {Buffer} buf */ | ||
| const onData = buf => { | ||
| properLastChunkReceived = Buffer.compare(buf.slice(-5), LAST_CHUNK) === 0; | ||
@@ -369,3 +365,14 @@ | ||
| previousChunk = buf; | ||
| }); | ||
| }; | ||
| socket.prependListener('close', onSocketClose); | ||
| socket.on('data', onData); | ||
| const removeSocketListeners = () => { | ||
| socket.removeListener('close', onSocketClose); | ||
| socket.removeListener('data', onData); | ||
| } | ||
| request.on('close', removeSocketListeners); | ||
| request.on('abort', removeSocketListeners); | ||
| }); | ||
@@ -372,0 +379,0 @@ } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
268839
0.4%4209
0.29%