Comparing version 4.0.0-alpha.1 to 4.0.0-alpha.2
@@ -432,5 +432,5 @@ 'use strict' | ||
wasm_on_headers_complete: p => { | ||
const statusCode = llhttp.llhttp_get_status_code(p) | ||
const upgrade = Boolean(llhttp.llhttp_get_upgrade(p)) | ||
const shouldKeepAlive = Boolean(llhttp.llhttp_should_keep_alive(p)) | ||
const statusCode = llhttp.exports.llhttp_get_status_code(p) | ||
const upgrade = Boolean(llhttp.exports.llhttp_get_upgrade(p)) | ||
const shouldKeepAlive = Boolean(llhttp.exports.llhttp_should_keep_alive(p)) | ||
return currentParser.onHeadersComplete(statusCode, upgrade, shouldKeepAlive) || 0 | ||
@@ -449,3 +449,3 @@ }, | ||
} | ||
}).exports | ||
}) | ||
@@ -456,7 +456,6 @@ class Parser { | ||
this.ptr = llhttp.llhttp_alloc(constants.TYPE.RESPONSE) | ||
this.ptr = llhttp.exports.llhttp_alloc(constants.TYPE.RESPONSE) | ||
this.bufferSize = 0 | ||
this.bufferPtr = null | ||
this.bufferRef = null | ||
this.bufferView = null | ||
this.client = client | ||
@@ -478,10 +477,9 @@ this.socket = socket | ||
resume () { | ||
if (!this.ptr) { | ||
if (this.ptr == null) { | ||
return | ||
} | ||
assert(this.ptr) | ||
assert(!currentParser) | ||
llhttp.llhttp_resume(this.ptr) | ||
llhttp.exports.llhttp_resume(this.ptr) | ||
@@ -503,7 +501,6 @@ if (this.timeout) { | ||
execute (data) { | ||
if (!this.ptr) { | ||
if (this.ptr == null) { | ||
return | ||
} | ||
assert(this.ptr) | ||
assert(!currentParser) | ||
@@ -516,13 +513,16 @@ | ||
if (this.bufferPtr) { | ||
llhttp.free(this.bufferPtr) | ||
llhttp.exports.free(this.bufferPtr) | ||
} | ||
this.bufferSize = Math.ceil(data.length / 4096) * 4096 | ||
this.bufferPtr = llhttp.malloc(this.bufferSize) | ||
// Instantiate a Unit8 Buffer view of the wasm memory that starts from the parser buffer pointer. | ||
this.bufferView = new Uint8Array(llhttp.memory.buffer, this.bufferPtr, this.bufferSize) | ||
this.bufferPtr = llhttp.exports.malloc(this.bufferSize) | ||
} | ||
// TODO (perf): Can we avoid this copy somehow? | ||
this.bufferView.set(data) | ||
if (data.length) { | ||
assert(this.bufferPtr != null) | ||
assert(this.bufferSize >= data.length) | ||
// TODO (perf): Can we avoid this copy somehow? | ||
new Uint8Array(llhttp.exports.memory.buffer, this.bufferPtr, this.bufferSize).set(data) | ||
} | ||
// Call `execute` on the wasm parser. | ||
@@ -534,3 +534,3 @@ // We pass the `llhttp_parser` pointer address, the pointer address of buffer view data, | ||
currentParser = this | ||
const ret = llhttp.llhttp_execute(this.ptr, this.bufferPtr, data.length) | ||
const ret = llhttp.exports.llhttp_execute(this.ptr, this.bufferPtr, data.length) | ||
currentParser = null | ||
@@ -543,3 +543,3 @@ this.bufferRef = null | ||
const offset = llhttp.llhttp_get_error_pos(this.ptr) - this.bufferPtr | ||
const offset = llhttp.exports.llhttp_get_error_pos(this.ptr) - this.bufferPtr | ||
@@ -552,7 +552,7 @@ if (ret === constants.ERROR.PAUSED_UPGRADE) { | ||
} else { | ||
const ptr = llhttp.llhttp_get_error_reason(this.ptr) | ||
const ptr = llhttp.exports.llhttp_get_error_reason(this.ptr) | ||
let message | ||
if (ptr) { | ||
const len = new Uint8Array(llhttp.memory.buffer).indexOf(0, ptr) - ptr | ||
message = Buffer.from(llhttp.memory.buffer, ptr, len).toString() | ||
const len = new Uint8Array(llhttp.exports.memory.buffer).indexOf(0, ptr) - ptr | ||
message = Buffer.from(llhttp.exports.memory.buffer, ptr, len).toString() | ||
} else { | ||
@@ -857,3 +857,3 @@ message = '' | ||
if (this.ptr) { | ||
llhttp.llhttp_free(this.ptr) | ||
llhttp.exports.llhttp_free(this.ptr) | ||
this.ptr = null | ||
@@ -863,3 +863,3 @@ } | ||
if (this.bufferPtr) { | ||
llhttp.free(this.bufferPtr) | ||
llhttp.exports.free(this.bufferPtr) | ||
this.bufferPtr = null | ||
@@ -866,0 +866,0 @@ } |
{ | ||
"name": "undici", | ||
"version": "4.0.0-alpha.1", | ||
"version": "4.0.0-alpha.2", | ||
"description": "An HTTP/1.1 client, written from scratch for Node.js", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/nodejs/undici#readme", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
362288
4636