Skip to content

Commit

Permalink
Catch abrupt SSL connection termination
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspervdj committed Jan 31, 2012
1 parent 1b2dfd3 commit e9f7988
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Snap/Internal/Http/Server/TLS.hs
Expand Up @@ -175,10 +175,13 @@ send tickleTimeout _ (NetworkSession _ aSSL sz) bs = go bs

------------------------------------------------------------------------------
recv :: IO b -> NetworkSession -> IO (Maybe ByteString)
recv _ (NetworkSession _ aSSL recvLen) = do
recv _ (NetworkSession _ aSSL recvLen) = handle termination $ do
b <- SSL.read ssl recvLen
return $! if S.null b then Nothing else Just b
where
ssl = unsafeCoerce aSSL

termination :: ConnectionAbruptlyTerminated -> IO (Maybe ByteString)
termination = const $ return Nothing

#endif

1 comment on commit e9f7988

@gregorycollins
Copy link
Member

Choose a reason for hiding this comment

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

Hey Jasper,

Do non-broken clients cause this exception to be generated? I think we do distinguish "connection reset by peer" from EOF in the normal socket situation, I would expect that this would be analogous for SSL. Just trying to understand the motivation here.

Please sign in to comment.