on master help sign in
Fix plain HTTP for warp-tls #324

@kazu-yamamoto I'm not exactly sure what the problem was with the previous code, but this version works, and has the expected semantics (chunk size is irrelevant in connRecv). Any objection?

commitc81177aecc9898ca1a887563dfe1141d63ca21e2 authorMichael Snoyman <michael@snoyman.com> dateSun 11 Jan 2015, 10:58 (12 years ago) parentd23b893
3 files changed+13−2
warp-tls/ChangeLog.md+4 warp-tls/Network/Wai/Handler/WarpTLS.hs+8−1 warp-tls/warp-tls.cabal+1−1
warp-tls/ChangeLog.md+4
@@ -1,3 +1,7 @@
1+## 3.0.1.3
2+
3+[Unable to allow insecure connections with warp-tls #324](https://github.com/yesodweb/wai/issues/324)
4+
15## 3.0.1.2
26
37[Make sure Timer is tickled in sendfile. #323](https://github.com/yesodweb/wai/pull/323)
warp-tls/Network/Wai/Handler/WarpTLS.hs+8−1
@@ -263,7 +263,14 @@ plainHTTP :: TLSSettings -> Socket -> I.IORef B.ByteString -> IO (Connection, Bo
263263plainHTTP TLSSettings{..} s cachedRef = case onInsecure of
264264 AllowInsecure -> do
265265 conn' <- socketConnection s
266− return (conn' { connRecv = getNext cachedRef s 4096 }, False)
266+ let newRecv = do
267+ bs <- I.readIORef cachedRef
268+ if B.null bs
269+ then connRecv conn'
270+ else do
271+ I.writeIORef cachedRef B.empty
272+ return bs
273+ return (conn' { connRecv = newRecv }, False)
267274 DenyInsecure lbs -> do
268275 sendAll s "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n"
269276 mapM_ (sendAll s) $ L.toChunks lbs
warp-tls/warp-tls.cabal+1−1
@@ -1,5 +1,5 @@
11Name: warp-tls
2−Version: 3.0.1.2
2+Version: 3.0.1.3
33Synopsis: HTTP over SSL/TLS support for Warp via the TLS package
44License: MIT
55License-file: LICENSE