Commit 2a5e9bc2 authored by Edward Z. Yang's avatar Edward Z. Yang Committed by GitHub
Browse files

Merge pull request #3841 from omefire/Bug_3795

WGET doesn't support range requests, so we should ignore them when using it
parents 8c400a40 eb0596b0
......@@ -420,10 +420,20 @@ curlTransport prog =
wgetTransport :: ConfiguredProgram -> HttpTransport
wgetTransport prog =
HttpTransport gethttp posthttp posthttpfile puthttpfile True False
HttpTransport gethttp posthttp posthttpfile puthttpfile True False
where
gethttp verbosity uri etag destPath reqHeaders = do
gethttp verbosity uri etag destPath reqHeaders = do
resp <- runWGet verbosity uri args
-- wget doesn't support range requests.
-- so, we not only ignore range request headers,
-- but we also dispay a warning message when we see them.
let hasRangeHeader = any (\hdr -> isRangeHeader hdr) reqHeaders
warningMsg = "the 'wget' transport currently doesn't support range requests, which wastes network bandwidth."
++ " To fix this, set 'http-transport' to 'curl' or 'plain-http' in '~/.cabal/config'."
++ " Note that the 'plain-http' transport doesn't support HTTPS.\n"
when (hasRangeHeader) $ warn verbosity warningMsg
(code, etag') <- parseOutput uri resp
return (code, etag')
where
......@@ -436,7 +446,13 @@ wgetTransport prog =
[ ["--header", "If-None-Match: " ++ t]
| t <- maybeToList etag ]
++ [ "--header=" ++ show name ++ ": " ++ value
| Header name value <- reqHeaders ]
| hdr@(Header name value) <- reqHeaders, (not (isRangeHeader hdr)) ]
-- wget doesn't support range requests.
-- so, we ignore range request headers, lest we get errors.
isRangeHeader :: Header -> Bool
isRangeHeader (Header HdrRange _) = True
isRangeHeader _ = False
posthttp = noPostYet
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment