Skip to content

Commit eebc867

Browse files
authored
Merge pull request #9116 from haskell/gh-9113-etag
Use case insensitive match on ETag headers
2 parents 3350a6c + d4d17d0 commit eebc867

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cabal-install/src/Distribution/Client/HttpUtils.hs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ import qualified Data.ByteString.Base16 as Base16
125125
import qualified Data.ByteString.Char8 as BS8
126126
import qualified Data.ByteString.Lazy as LBS
127127
import qualified Data.ByteString.Lazy.Char8 as LBS8
128+
import qualified Data.Char as Char
128129
import qualified Distribution.Compat.CharParsing as P
129130

130131
------------------------------------------------------------------------------
@@ -626,7 +627,8 @@ curlTransport prog =
626627
listToMaybe $
627628
reverse
628629
[ etag
629-
| ["ETag:", etag] <- map words (lines headers)
630+
| [name, etag] <- map words (lines headers)
631+
, isETag name
630632
]
631633
in case codeerr of
632634
Just (i, err) -> return (i, err, mb_etag)
@@ -776,7 +778,8 @@ wgetTransport prog =
776778
mb_etag =
777779
listToMaybe
778780
[ etag
779-
| ["ETag:", etag] <- map words (reverse (lines resp))
781+
| [name, etag] <- map words (reverse (lines resp))
782+
, isETag name
780783
]
781784
in case parsedCode of
782785
Just i -> return (i, mb_etag)
@@ -1146,3 +1149,6 @@ genBoundary :: IO String
11461149
genBoundary = do
11471150
i <- randomRIO (0x10000000000000, 0xFFFFFFFFFFFFFF) :: IO Integer
11481151
return $ showHex i ""
1152+
1153+
isETag :: String -> Bool
1154+
isETag name = fmap Char.toLower name == "etag:"

0 commit comments

Comments
 (0)