@@ -65,6 +65,7 @@ const {
6565 kLocalAddress,
6666 kMaxResponseSize
6767} = require ( './core/symbols' )
68+ const FastBuffer = Buffer [ Symbol . species ]
6869
6970const kClosedResolve = Symbol ( 'kClosedResolve' )
7071
@@ -363,8 +364,7 @@ async function lazyllhttp () {
363364 wasm_on_status : ( p , at , len ) => {
364365 assert . strictEqual ( currentParser . ptr , p )
365366 const start = at - currentBufferPtr
366- const end = start + len
367- return currentParser . onStatus ( currentBufferRef . slice ( start , end ) ) || 0
367+ return currentParser . onStatus ( new FastBuffer ( currentBufferRef . buffer , start , len ) ) || 0
368368 } ,
369369 wasm_on_message_begin : ( p ) => {
370370 assert . strictEqual ( currentParser . ptr , p )
@@ -373,14 +373,12 @@ async function lazyllhttp () {
373373 wasm_on_header_field : ( p , at , len ) => {
374374 assert . strictEqual ( currentParser . ptr , p )
375375 const start = at - currentBufferPtr
376- const end = start + len
377- return currentParser . onHeaderField ( currentBufferRef . slice ( start , end ) ) || 0
376+ return currentParser . onHeaderField ( new FastBuffer ( currentBufferRef . buffer , start , len ) ) || 0
378377 } ,
379378 wasm_on_header_value : ( p , at , len ) => {
380379 assert . strictEqual ( currentParser . ptr , p )
381380 const start = at - currentBufferPtr
382- const end = start + len
383- return currentParser . onHeaderValue ( currentBufferRef . slice ( start , end ) ) || 0
381+ return currentParser . onHeaderValue ( new FastBuffer ( currentBufferRef . buffer , start , len ) ) || 0
384382 } ,
385383 wasm_on_headers_complete : ( p , statusCode , upgrade , shouldKeepAlive ) => {
386384 assert . strictEqual ( currentParser . ptr , p )
@@ -389,8 +387,7 @@ async function lazyllhttp () {
389387 wasm_on_body : ( p , at , len ) => {
390388 assert . strictEqual ( currentParser . ptr , p )
391389 const start = at - currentBufferPtr
392- const end = start + len
393- return currentParser . onBody ( currentBufferRef . slice ( start , end ) ) || 0
390+ return currentParser . onBody ( new FastBuffer ( currentBufferRef . buffer , start , len ) ) || 0
394391 } ,
395392 wasm_on_message_complete : ( p ) => {
396393 assert . strictEqual ( currentParser . ptr , p )
0 commit comments