haskell / haskell/cabal

Make timeout/retries configurable for HTTP transports

Open
#3,386 0 comments 0 reactions 0 assignees View on GitHub
cabal-install: other re: http-transport type: enhancement
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

`cabal --help` shows support for a few transport methods:

```
--http-transport=HttpTransport Set a transport for http(s) requests.
Accepts 'curl', 'wget', 'powershell', and
'plain-http'. (default: 'curl')
```

Right now the timeout/retry configuration seems to be adhoc, e.g. `wget` gets passed hardwired `--tries`/`--timeout` values.

```haskell
wgetTransport :: ConfiguredProgram -> HttpTransport
wgetTransport prog =
HttpTransport gethttp posthttp posthttpfile puthttpfile True False
where
gethttp verbosity uri etag destPath reqHeaders = do
resp <- runWGet verbosity uri args
(code, _err, etag') <- parseResponse uri resp
return (code, etag')
where
args = [ "--output-document=" ++ destPath
, "--user-agent=" ++ userAgent
, "--tries=5"
, "--timeout=15"
, "--server-response" ]
++ concat
[ ["--header", "If-None-Match: " ++ t]
| t <- maybeToList etag ]
++ [ "--header=" ++ show name ++ ": " ++ value
| Header name value <- reqHeaders ]
```

Whereas e.g. `curl` is left at its default settings. For the mirror-fallback logic (e.g. when shall the code consider hackage.h.o to be down and cycle to the next available mirror?) we may want to have more control over these settings in order to allow the user to fine-tune/experiment to his environment (as well as provide us empirical data to inform the selection of good defaults).

/cc @gbaz

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.