Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ipull

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipull - npm Package Compare versions

Comparing version 3.9.0 to 3.9.1

2

dist/download/download-engine/streams/download-engine-fetch-stream/download-engine-fetch-stream-fetch.d.ts
import BaseDownloadEngineFetchStream, { DownloadInfoResponse, FetchSubState, WriteCallback } from "./base-download-engine-fetch-stream.js";
type GetNextChunk = () => Promise<ReadableStreamReadResult<Uint8Array>> | ReadableStreamReadResult<Uint8Array>;
export default class DownloadEngineFetchStreamFetch extends BaseDownloadEngineFetchStream {
private _fetchDownloadInfoWithHEAD;
transferAction: string;

@@ -8,2 +9,3 @@ withSubState(state: FetchSubState): this;

protected fetchDownloadInfoWithoutRetry(url: string): Promise<DownloadInfoResponse>;
protected fetchDownloadInfoWithoutRetryByMethod(url: string, method?: "HEAD" | "GET"): Promise<DownloadInfoResponse>;
protected fetchDownloadInfoWithoutRetryContentRange(url: string): Promise<number>;

@@ -10,0 +12,0 @@ chunkGenerator(callback: WriteCallback, getNextChunk: GetNextChunk): Promise<void>;

@@ -9,2 +9,3 @@ import BaseDownloadEngineFetchStream, { MIN_LENGTH_FOR_MORE_INFO_REQUEST } from "./base-download-engine-fetch-stream.js";

export default class DownloadEngineFetchStreamFetch extends BaseDownloadEngineFetchStream {
_fetchDownloadInfoWithHEAD = false;
transferAction = "Downloading";

@@ -43,4 +44,18 @@ withSubState(state) {

async fetchDownloadInfoWithoutRetry(url) {
if (this._fetchDownloadInfoWithHEAD) {
try {
return this.fetchDownloadInfoWithoutRetryByMethod(url, "HEAD");
}
catch (error) {
if (!(error instanceof StatusCodeError)) {
throw error;
}
this._fetchDownloadInfoWithHEAD = false;
}
}
return this.fetchDownloadInfoWithoutRetryByMethod(url, "GET");
}
async fetchDownloadInfoWithoutRetryByMethod(url, method = "HEAD") {
const response = await fetch(url, {
method: "HEAD",
method: method,
headers: {

@@ -57,3 +72,3 @@ "Accept-Encoding": "identity",

let length = parseInt(response.headers.get("content-length")) || 0;
if (response.headers.get("content-encoding") || browserCheck() && MIN_LENGTH_FOR_MORE_INFO_REQUEST < length) {
if (method != "GET" && response.headers.get("content-encoding") || browserCheck() && MIN_LENGTH_FOR_MORE_INFO_REQUEST < length) {
length = acceptRange ? await this.fetchDownloadInfoWithoutRetryContentRange(url) : 0;

@@ -60,0 +75,0 @@ }

import BaseDownloadEngineFetchStream, { DownloadInfoResponse, FetchSubState, WriteCallback } from "./base-download-engine-fetch-stream.js";
import { AvailablePrograms } from "../../download-file/download-programs/switch-program.js";
export default class DownloadEngineFetchStreamXhr extends BaseDownloadEngineFetchStream {
private _fetchDownloadInfoWithHEAD;
readonly programType: AvailablePrograms;

@@ -14,4 +15,5 @@ transferAction: string;

protected fetchDownloadInfoWithoutRetry(url: string): Promise<DownloadInfoResponse>;
protected fetchDownloadInfoWithoutRetryByMethod(url: string, method?: "HEAD" | "GET"): Promise<DownloadInfoResponse>;
protected fetchDownloadInfoWithoutRetryContentRange(url: string): Promise<number>;
protected static convertXHRHeadersToRecord(xhr: XMLHttpRequest): Record<string, string>;
}

@@ -10,2 +10,3 @@ import BaseDownloadEngineFetchStream, { MIN_LENGTH_FOR_MORE_INFO_REQUEST } from "./base-download-engine-fetch-stream.js";

export default class DownloadEngineFetchStreamXhr extends BaseDownloadEngineFetchStream {
_fetchDownloadInfoWithHEAD = true;
programType = "chunks";

@@ -106,5 +107,19 @@ transferAction = "Downloading";

fetchDownloadInfoWithoutRetry(url) {
if (this._fetchDownloadInfoWithHEAD) {
try {
return this.fetchDownloadInfoWithoutRetryByMethod(url, "HEAD");
}
catch (error) {
if (!(error instanceof StatusCodeError)) {
throw error;
}
this._fetchDownloadInfoWithHEAD = false;
}
}
return this.fetchDownloadInfoWithoutRetryByMethod(url, "GET");
}
async fetchDownloadInfoWithoutRetryByMethod(url, method = "HEAD") {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.open("HEAD", url, true);
xhr.open(method, url, true);
const allHeaders = {

@@ -119,3 +134,3 @@ ...this.options.headers

const contentLength = parseInt(xhr.getResponseHeader("content-length"));
const length = MIN_LENGTH_FOR_MORE_INFO_REQUEST < contentLength ? await this.fetchDownloadInfoWithoutRetryContentRange(url) : 0;
const length = MIN_LENGTH_FOR_MORE_INFO_REQUEST < contentLength && method != "GET" ? await this.fetchDownloadInfoWithoutRetryContentRange(url) : 0;
const fileName = parseContentDisposition(xhr.getResponseHeader("content-disposition"));

@@ -122,0 +137,0 @@ const acceptRange = this.options.acceptRangeIsKnown ?? xhr.getResponseHeader("Accept-Ranges") === "bytes";

25

dist/download/transfer-visualize/transfer-cli/cli-animation-wrapper.js

@@ -42,15 +42,20 @@ import switchCliProgressStyle from "./progress-bars/switch-cli-progress-style.js";

this._activeCLI.loadingAnimation.start();
const engine = await this._downloadEngine;
this._activeCLI.loadingAnimation.stop();
engine.once("start", () => {
this._activeCLI?.start();
engine.on("progress", (progress) => {
this._activeCLI?.updateStatues(engine.downloadStatues, progress);
try {
const engine = await this._downloadEngine;
this._activeCLI.loadingAnimation.stop();
engine.once("start", () => {
this._activeCLI?.start();
engine.on("progress", (progress) => {
this._activeCLI?.updateStatues(engine.downloadStatues, progress);
});
engine.on("closed", () => {
this._activeCLI?.stop();
});
});
engine.on("closed", () => {
this._activeCLI?.stop();
});
});
}
finally {
this._activeCLI.loadingAnimation.stop();
}
}
}
//# sourceMappingURL=cli-animation-wrapper.js.map
{
"name": "ipull",
"version": "3.9.0",
"version": "3.9.1",
"description": "The only file downloader you'll ever need. For node.js and the browser, CLI and library for fast and reliable file downloads.",

@@ -103,2 +103,3 @@ "main": "dist/index.js",

"@types/async-retry": "^1.4.8",
"@types/express": "^5.0.0",
"@types/fs-extra": "^11.0.1",

@@ -116,2 +117,3 @@ "@types/lodash.debounce": "^4.0.9",

"eslint-plugin-node": "^11.1.0",
"express": "^4.21.1",
"hash.js": "^1.1.7",

@@ -118,0 +120,0 @@ "husky": "^8.0.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc