MCPcopy Index your code
hub / github.com/nodejs/node / execute

Method execute

deps/undici/undici.js:7248–7288  ·  view source on GitHub ↗

* @param {Buffer} chunk

(chunk)

Source from the content-addressed store, hash-verified

7246 * @param {Buffer} chunk
7247 */
7248 execute(chunk) {
7249 assert(currentParser === null);
7250 assert(this.ptr != null);
7251 assert(!this.paused);
7252 const { socket, llhttp } = this;
7253 if (chunk.length > currentBufferSize) {
7254 if (currentBufferPtr) {
7255 llhttp.free(currentBufferPtr);
7256 }
7257 currentBufferSize = Math.ceil(chunk.length / 4096) * 4096;
7258 currentBufferPtr = llhttp.malloc(currentBufferSize);
7259 }
7260 if (currentBuffer === null || currentBuffer.buffer !== llhttp.memory.buffer || currentBuffer.byteOffset !== currentBufferPtr || currentBuffer.byteLength !== currentBufferSize) {
7261 currentBuffer = new Uint8Array(llhttp.memory.buffer, currentBufferPtr, currentBufferSize);
7262 }
7263 currentBuffer.set(chunk);
7264 try {
7265 let ret;
7266 try {
7267 currentBufferRef = chunk;
7268 currentParser = this;
7269 ret = llhttp.llhttp_execute(this.ptr, currentBufferPtr, chunk.length);
7270 } finally {
7271 currentParser = null;
7272 currentBufferRef = null;
7273 }
7274 if (ret !== constants.ERROR.OK) {
7275 const data = chunk.subarray(llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr);
7276 if (ret === constants.ERROR.PAUSED_UPGRADE) {
7277 this.onUpgrade(data);
7278 } else if (ret === constants.ERROR.PAUSED) {
7279 this.paused = true;
7280 socket.unshift(data);
7281 } else {
7282 throw this.createError(ret, data);
7283 }
7284 }
7285 } catch (err) {
7286 util.destroy(socket, err);
7287 }
7288 }
7289 finish() {
7290 assert(currentParser === null);
7291 assert(this.ptr != null);

Callers 6

socketOnDataFunction · 0.45
socketOnDataFunction · 0.45
processHeaderFragmentedFunction · 0.45
processHeaderFunction · 0.45
resumeMethod · 0.45
readMoreMethod · 0.45

Calls 7

freeMethod · 0.80
unshiftMethod · 0.80
assertFunction · 0.50
setMethod · 0.45
onUpgradeMethod · 0.45
createErrorMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected