serverless-express icon indicating copy to clipboard operation
serverless-express copied to clipboard

Chunked transfer encoding

Open denneulin opened this issue 10 years ago • 8 comments

Hi,

I use an express middleware that set to chunked the transfer-encoding headers

'transfer-encoding': 'chunked'

In that case, I get the following error :

The request could not be satisfied. CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.

To make my request works, in the forwardResponseToApiGateway function of the aws-serverless-express/index.js file I remove this header.

Do you think you could make chunked transfert encoding pass ?

denneulin avatar Oct 19 '16 14:10 denneulin

Chunked transfer is something we are looking into; unfortunately, for now you will need to disable it.

On Wed, 19 Oct 2016, 07:25 Anthony Denneulin, [email protected] wrote:

Hi,

I use an express middleware that set to chunked the transfer-encoding headers

'transfer-encoding': 'chunked'

In that case, I get the following error :

The request could not be satisfied. CloudFront attempted to establish a connection with the origin, but either the attempt failed or the origin closed the connection.

To make my request works, in the forwardResponseToApiGateway function of the aws-serverless-express/index.js file I remove this header.

Do you think you could make chunked transfert encoding pass ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/awslabs/aws-serverless-express/issues/10, or mute the thread https://github.com/notifications/unsubscribe-auth/ABy6l2mkJhh8RIJXLdgJxYJNydLZImRBks5q1ihQgaJpZM4KbCVz .

brettstack avatar Oct 19 '16 14:10 brettstack

That's really annoying but thanks for your answer ;)

denneulin avatar Oct 19 '16 14:10 denneulin

Why is this closed? Is it solved?

goldenbearkin avatar Nov 11 '16 09:11 goldenbearkin

This is a limitation with API Gateway, and not the library. However, I will reopen this issue for tracking and notification purposes.

brettstack avatar Nov 11 '16 14:11 brettstack

Thanks brettstack. for those seeking a temporary solution mentioned by @denneulin above. Add 'delete headers' as below in the forwardResponseToApiGateway function.

delete headers["transfer-encoding"]
const successResponse = {statusCode, body, headers}

goldenbearkin avatar Nov 13 '16 09:11 goldenbearkin

This should be working now. You don't need to explicitly remove the 'transfer-encoding' header anymore.

abhigna avatar Dec 23 '16 22:12 abhigna

@abhigna I think the transfer-encoding: chunked issue still exists. I've tried to use aws-serverless-express with graphql-server-express today and I run into the same issue as @denneulin

ckuijjer avatar Jan 27 '17 12:01 ckuijjer

Chunked encoding still isn't working, but we are now deleting the header for you https://github.com/awslabs/aws-serverless-express/commit/4d54a81b831eca97524f15b72fa8be379c80aedb#diff-168726dbe96b3ce427e7fedce31bb0bcR54

brettstack avatar Mar 18 '17 17:03 brettstack