Skip to content

Commit

Permalink
Set "Connection: close" for non-keep-alive requests
Browse files Browse the repository at this point in the history
According to the HTTP 1.1 Spec:

> An HTTP/1.1 server MAY assume that a HTTP/1.1 client intends to
> maintain a persistent connection unless a Connection header including
> the connection-token "close" was sent in the request. If the server
> chooses to close the connection immediately after sending the
> response, it SHOULD send a Connection header including the
> connection-token close.
https://www.rfc-editor.org/rfc/rfc2616#section-8.1.2.1

The Node.js `Request` module depends on getting the header `Connection:
close` to properly sequence socket messages, otherwise it throws a
"socket hang up" error.

This issue was found due to Remix having a custom implementation of
`fetch` that use's Node.js's `Request` module, which has different
behavior than the native Node.js `fetch` global.
  • Loading branch information
scotttrinh committed Mar 20, 2024
1 parent ac377d1 commit 43952a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion edb/server/protocol/protocol.pyx
Expand Up @@ -360,7 +360,7 @@ cdef class HttpProtocol:
response.content_type,
response.custom_headers,
response.body,
response.close_connection)
response.close_connection or not request.should_keep_alive)

def _switch_to_binary_protocol(self, data=None):
binproto = binary.new_edge_connection(
Expand Down

0 comments on commit 43952a6

Please sign in to comment.