You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While implementing my other PR, I noticed that trailing headers are not supported and using them blocks the response until the timeout of the serverless runtime.
The used constant endChunked = '0\r\n\r\n'; does not respect trailing headers.
The trailing headers may be added in between the two CRLFs.
I do not suggest to fix it right away, it should just be kept on radar and be documented.
As far as I can tell, trailing headers are aside from checksums not very broadly used.
Current Behavior
A response will never finish when trailing headers are set.
Expected Behavior
Response with trailing headers are sent normally.
Steps to Reproduce the Problem
it('should return the correct bytes of chunked stream with trailing headers',async()=>{constapp=express();constfile=readFileSync(join(__dirname,'bitcoin.pdf'));app.get('/',(_,res)=>{constreadable=createReadStream(join(__dirname,'bitcoin.pdf'));res.statusCode=200;res.setHeader('content-type','application/pdf');res.setHeader('Trailer','Content-MD5');res.flushHeaders();readable.pipe(res);// add trailing headersres.addTrailers({'Content-MD5': '7895bf4b8828b55ceaf47747b4bca667'});});constexpressFramework=newExpressFramework();consthandler=awsStreamHandler.getHandler(app,expressFramework,adapters,resolver,binarySettings,respondWithErrors,logger,);constevent=createApiGatewayV2('GET','/',{},{test: 'true'});constcontext={test: Symbol('unique')};constwritable=newWritableMock();// check if handled in timelethandledInTime=true;awaitPromise.race([handler(event,writable,context),newPromise(resolve=>{setTimeout(()=>{handledInTime=false;resolve(undefined);},1000);}),]);expect(handledInTime).toBeTruthy();expect(getCurrentInvoke()).toHaveProperty('event',event);expect(getCurrentInvoke()).toHaveProperty('context',context);constfinalBuffer=Buffer.concat(writable.data);expect(Buffer.byteLength(finalBuffer)).toBe(Buffer.byteLength(file));});
Environment
All
The text was updated successfully, but these errors were encountered:
While implementing my other PR, I noticed that trailing headers are not supported and using them blocks the response until the timeout of the serverless runtime.
The used constant
endChunked = '0\r\n\r\n';
does not respect trailing headers.The trailing headers may be added in between the two CRLFs.
I do not suggest to fix it right away, it should just be kept on radar and be documented.
As far as I can tell, trailing headers are aside from checksums not very broadly used.
Current Behavior
A response will never finish when trailing headers are set.
Expected Behavior
Response with trailing headers are sent normally.
Steps to Reproduce the Problem
Environment
The text was updated successfully, but these errors were encountered: