Skip to content

Commit

Permalink
Send content length header.
Browse files Browse the repository at this point in the history
  • Loading branch information
jroith authored and martijnwalraven committed Oct 25, 2017
1 parent a0fd02c commit 671d196
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/apollo-server-express/src/expressApollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export function graphqlExpress(options: GraphQLOptions | ExpressGraphQLOptionsFu
query: req.method === 'POST' ? req.body : req.query,
}).then((gqlResponse) => {
res.setHeader('Content-Type', 'application/json');
res.setHeader('Content-Length', Buffer.byteLength(gqlResponse, 'utf8'));
res.write(gqlResponse);
res.end();
}, (error: HttpQueryError) => {
Expand Down

1 comment on commit 671d196

@ribizli
Copy link

@ribizli ribizli commented on 671d196 Jan 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this change has led us to this ugly nodeJS http bug: nodejs/node#13391
Sending a response through a slow connection caused Content-Length mismatch after the response was truncated.
Solution: upgrade nodeJS v8.8.0 or set server.keepAliveTimeout = 120000 (or a reasonably high value)

Please sign in to comment.