[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#931715: please update to 0.6.4



Sean Whitton wrote:
> Looks like it's not in Stackage LTS yet.  I see you wrote the patch.
> Would it be enough to backport it to what's currently in sid?

Patch backport attached.

-- 
see shy jo
diff -ur haskell-http-client-0.5.13.1.orig/Network/HTTP/Client/Headers.hs haskell-http-client-0.5.13.1/Network/HTTP/Client/Headers.hs
--- haskell-http-client-0.5.13.1.orig/Network/HTTP/Client/Headers.hs	2018-04-09 09:40:11.000000000 -0400
+++ haskell-http-client-0.5.13.1/Network/HTTP/Client/Headers.hs	2019-07-09 11:37:17.499256981 -0400
@@ -84,13 +84,20 @@
         if S.null line
             then return $ front []
             else do
-                header <- parseHeader line
-                parseHeaders (count + 1) $ front . (header:)
+                mheader <- parseHeader line
+                case mheader of
+                    Just header ->
+                        parseHeaders (count + 1) $ front . (header:)
+                    Nothing ->
+                        -- Unparseable header line; rather than throwing
+                        -- an exception, ignore it for robustness.
+                        parseHeaders count front
 
-    parseHeader :: S.ByteString -> IO Header
+    parseHeader :: S.ByteString -> IO (Maybe Header)
     parseHeader bs = do
         let (key, bs2) = S.break (== charColon) bs
-        when (S.null bs2) $ throwHttp $ InvalidHeader bs
-        return (CI.mk $! strip key, strip $! S.drop 1 bs2)
+        if S.null bs2
+            then return Nothing
+            else return (Just (CI.mk $! strip key, strip $! S.drop 1 bs2))
 
     strip = S.dropWhile (== charSpace) . fst . S.spanEnd (== charSpace)

Attachment: signature.asc
Description: PGP signature


Reply to: