Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanly close connection when client closes connection prematurely #844

Merged
merged 1 commit into from
May 19, 2021

Conversation

larskuhtz
Copy link
Contributor

The function Network.Socket.ByteString.recv returns a ByteString of length zero when the connection has been closed.
The mkConn function does not handle that special case and instead calls plainHTTP, which raises a spurious InsecureConnectionDemied Exception. On the client side http-client-tls (and probably most other clients) reacts to this with an ungraceful connection reset.

This PR adds a new ClientClosedConnectionPrematurely constructor to WarpTLSException. When the client closes a connection immediately after the opening handshake and before the TLS "hello" message, the connection is gracefully closed and a ClientClosedConnectionPrematurely exception is raised.

Before submitting your PR, check that you've:

After submitting your PR:

  • Update the Changelog.md file with a link to your PR
  • Check that CI passes (or if it fails, for reasons unrelated to your change, like CI timeouts)

@snoyberg
Copy link
Member

@kazu-yamamoto this looks reasonable to me, but I think you'd be in a better position to review.

@kazu-yamamoto kazu-yamamoto self-requested a review May 18, 2021 11:32
Copy link
Contributor

@kazu-yamamoto kazu-yamamoto left a comment

Choose a reason for hiding this comment

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

Looks excellent to me!

@kazu-yamamoto kazu-yamamoto merged commit d7f6454 into yesodweb:master May 19, 2021
@kazu-yamamoto
Copy link
Contributor

Merged. Thank you for your contribution!

@kazu-yamamoto
Copy link
Contributor

A new version of warp-tls has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants