packages feed

http-proxy 0.0.7 → 0.0.8

raw patch · 2 files changed

+16/−22 lines, 2 files

Files

Network/HTTP/Proxy.hs view
@@ -489,6 +489,7 @@     needsChunked hs = isChunked' && not (hasLength hs)     isKeepAlive hs = isPersist && (isChunked' || hasLength hs)     hasLength hs = isJust $ lookup "content-length" hs+    sendHeader = connSendMany conn . L.toChunks . toLazyByteString      sendResponse' :: Response -> ResourceT IO Bool     sendResponse' ResponseFile{} = error "Proxy cannot send a file."@@ -500,10 +501,7 @@                 T.tickle th) body               return (isKeepAlive hs)         | otherwise = liftIO $ do-            connSendMany conn-                $ L.toChunks-                $ toLazyByteString-                $ headers' False+            sendHeader $ headers' False             T.tickle th             return isPersist       where@@ -515,8 +513,16 @@                        `mappend` chunkedTransferTerminator                   else headers' False `mappend` b -    sendResponse' (ResponseSource s hs bodyFlush) =-        response+    sendResponse' (ResponseSource s hs bodyFlush)+        | hasBody s req = do+            let src = CL.sourceList [headers' needsChunked'] `mappend`+                      (if needsChunked' then body C.$= chunk else body)+            src C.$$ builderToByteString C.=$ connSink conn th+            return $ isKeepAlive hs+        | otherwise = liftIO $ do+            sendHeader $ headers' False+            T.tickle th+            return isPersist       where         body = fmap (\x -> case x of                         C.Flush -> flush@@ -524,26 +530,12 @@         headers' = headers version s hs         -- FIXME perhaps alloca a buffer per thread and reuse that in all         -- functions below. Should lessen greatly the GC burden (I hope)-        response-            | not (hasBody s req) = liftIO $ do-                connSendMany conn-                   $ L.toChunks $ toLazyByteString-                   $ headers' False-                T.tickle th-                return (checkPersist req)-            | otherwise = do-                let src =-                        CL.sourceList [headers' needsChunked'] `mappend`-                        (if needsChunked' then body C.$= chunk else body)-                src C.$$ builderToByteString C.=$ connSink conn th-                return $ isKeepAlive hs         needsChunked' = needsChunked hs         chunk :: C.Conduit Builder IO Builder         chunk = C.Conduit             { C.conduitPush = push             , C.conduitClose = close             }-         conduit = C.Conduit push close         push x = return $ C.Producing conduit [chunkedTransferEncoding x]         close = return [chunkedTransferTerminator]@@ -812,7 +804,7 @@                 fromUpstream <- C.bufferSource $ connSource uconn th                 liftIO $                     connSendMany conn $ L.toChunks $ toLazyByteString-                                      $ headers (httpVersion req) H.statusOK [] False+                                      $ headers (httpVersion req) statusConnectOK [] False                 void $ with (forkIO $ do                             wrTh <- T.registerKillThread tm                             runResourceT (fromUpstream C.$$ connSink conn wrTh)@@ -824,6 +816,8 @@             Left errorMsg ->                 failRequest th conn req errorMsg ("PROXY FAILURE\r\n" `mappend` errorMsg) +statusConnectOK :: H.Status+statusConnectOK = H.Status 200 "Connection established"  connectTo :: HostName   -- Hostname           -> PortID     -- Port Identifier
http-proxy.cabal view
@@ -1,5 +1,5 @@ Name:           http-proxy-Version:        0.0.7+Version:        0.0.8 License:        BSD3 License-file:   LICENSE Author:         Michael Snoyman, Stephen Blackheath, Erik de Castro Lopo