@ossiana/node-libcurl
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -189,2 +189,4 @@ export declare enum LibCurlHttpVersionInfo { | ||
setAkamaiFingerprint(akamai: LibCurlAkamaiFingerPrintInfo): void; | ||
setHttp2NextStreamId(stream_id: number): void; | ||
setHttp2StreamWeight(weight: number): void; | ||
private beforeProcessRequestHeaders; | ||
@@ -191,0 +193,0 @@ send(body?: LibCurlBodyInfo): Promise<undefined> | undefined; |
@@ -142,2 +142,3 @@ "use strict"; | ||
exports.LibCurlError = LibCurlError; | ||
const textEncoder = new TextEncoder(); | ||
class LibCurl { | ||
@@ -270,3 +271,5 @@ m_libCurl_impl_; | ||
.filter((header) => header.includes(": ")); | ||
return new Headers(lines.map((line) => line.split(": ", 2))); | ||
return new Headers(lines.map((line) => line | ||
.split(": ", 2) | ||
.map((e) => String.fromCharCode(...textEncoder.encode(e))))); | ||
} | ||
@@ -343,2 +346,5 @@ getResponseStatus() { | ||
const extension_permutation = extensions.map((extension) => { | ||
if (extension == 41) { | ||
return 127; | ||
} | ||
const pos = LibCurlBoringSSLExtensionPermutation.indexOf(extension); | ||
@@ -365,2 +371,14 @@ if (pos == -1) { | ||
} | ||
setHttp2NextStreamId(stream_id) { | ||
if (stream_id < 1 || stream_id % 2 == 0) { | ||
throw new LibCurlError("stream_id error"); | ||
} | ||
this.m_libCurl_impl_.setHttp2NextStreamId(stream_id); | ||
} | ||
setHttp2StreamWeight(weight) { | ||
if (weight < 0 || weight > 256) { | ||
throw new LibCurlError("weight error"); | ||
} | ||
this.m_libCurl_impl_.setHttp2StreamWeight(weight); | ||
} | ||
beforeProcessRequestHeaders(contentLength) { | ||
@@ -487,3 +505,3 @@ if (typeof contentLength == "number") { | ||
this.m_isSending_ = true; | ||
const isSubmitBody = !["GET", "HEAD"].includes(this.m_method_); | ||
const isSubmitBody = !["GET", "HEAD", "OPTIONS"].includes(this.m_method_); | ||
let promise; | ||
@@ -490,0 +508,0 @@ if (body) { |
@@ -66,2 +66,6 @@ import { LibCurl, LibCurlBodyInfo, LibCurlCookiesAttr, LibCurlCookiesInfo, LibCurlHeadersInfo, LibCurlProxyInfo, LibCurlHttpVersionInfo, LibCurlURLInfo, LibCurlJA3FingerPrintInfo, LibCurlAkamaiFingerPrintInfo } from "./libcurl"; | ||
httpVersion?: requestsHttpVersionInfo; | ||
h2config?: { | ||
weight: number; | ||
streamId: number; | ||
}; | ||
} | ||
@@ -94,2 +98,3 @@ interface requestsStaticOption extends Omit<requestsInitOption, "body" | "instance">, requestsOption { | ||
static delete(url: requestsURLInfo, requestOpt?: requestsStaticOption): Promise<requestsResponse>; | ||
static options(url: requestsURLInfo, requestOpt?: requestsStaticOption): Promise<requestsResponse>; | ||
get(url: requestsURLInfo, requestOpt?: requestsOption): Promise<requestsResponse>; | ||
@@ -102,2 +107,3 @@ post(url: requestsURLInfo, requestOpt?: requestsOption): Promise<requestsResponse>; | ||
delete(url: requestsURLInfo, requestOpt?: requestsOption): Promise<requestsResponse>; | ||
options(url: requestsURLInfo, requestOpt?: requestsOption): Promise<requestsResponse>; | ||
setCookie(key: string, value: string, domain: string, path?: string): void; | ||
@@ -104,0 +110,0 @@ getCookie(key: string, domain?: string, path?: string): string; |
@@ -143,3 +143,3 @@ "use strict"; | ||
const { instance: curl, timeout: timeoutOpt, ja3, akamai } = this.option; | ||
const { headers, data, json, params, timeout, interface: interface_, redirect, proxy, httpVersion, } = requestOpt || {}; | ||
const { headers, data, json, params, timeout, interface: interface_, redirect, proxy, httpVersion, h2config, } = requestOpt || {}; | ||
if (data && json) { | ||
@@ -209,2 +209,6 @@ throw new libcurl_1.LibCurlError("both data and json exist"); | ||
} | ||
if (h2config) { | ||
curl.setHttp2NextStreamId(h2config.streamId); | ||
curl.setHttp2StreamWeight(h2config.weight); | ||
} | ||
let hasContentType = false; | ||
@@ -329,2 +333,5 @@ if (headers && (data || json)) { | ||
} | ||
static async options(url, requestOpt) { | ||
return requests.sendRequestStaic("OPTIONS", url, requestOpt); | ||
} | ||
async get(url, requestOpt) { | ||
@@ -351,2 +358,5 @@ return this.sendRequestRetry("GET", url, requestOpt); | ||
} | ||
async options(url, requestOpt) { | ||
return this.sendRequestRetry("OPTIONS", url, requestOpt); | ||
} | ||
setCookie(key, value, domain, path = "") { | ||
@@ -353,0 +363,0 @@ this.option.instance.setCookie({ |
@@ -101,3 +101,3 @@ "use strict"; | ||
} | ||
return `771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,${extensions.join("-")},25497-29-23-24,0`; | ||
return `771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,${extensions.join("-")}-41,25497-29-23-24,0`; | ||
}; | ||
@@ -104,0 +104,0 @@ exports.libcurlRandomJA3Fingerprint = libcurlRandomJA3Fingerprint; |
{ | ||
"name": "@ossiana/node-libcurl", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"author": { | ||
@@ -32,7 +32,7 @@ "name": "Ossian" | ||
"optionalDependencies": { | ||
"@ossiana/node-libcurl-darwin-x64": "1.6.0", | ||
"@ossiana/node-libcurl-darwin-arm64": "1.6.0", | ||
"@ossiana/node-libcurl-linux-x64-gnu": "1.6.0", | ||
"@ossiana/node-libcurl-linux-arm64-gnu": "1.6.0", | ||
"@ossiana/node-libcurl-win32-x64-msvc": "1.6.0" | ||
"@ossiana/node-libcurl-darwin-x64": "1.6.1", | ||
"@ossiana/node-libcurl-darwin-arm64": "1.6.1", | ||
"@ossiana/node-libcurl-linux-x64-gnu": "1.6.1", | ||
"@ossiana/node-libcurl-linux-arm64-gnu": "1.6.1", | ||
"@ossiana/node-libcurl-win32-x64-msvc": "1.6.1" | ||
}, | ||
@@ -53,3 +53,3 @@ "main": "./dist/index.js", | ||
}, | ||
"artifacts-version": "v1.0.7" | ||
"artifacts-version": "v1.0.8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
117193
1828