aboutsummaryrefslogtreecommitdiff
path: root/bpkg/fetch.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-07-21 20:19:15 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-07-25 17:09:35 +0300
commitfd4439e4d067f77642b3f3dfcaf50d605e69235f (patch)
treee72cabbd3e931021a8ccbf80943fb6d9cc8531b6 /bpkg/fetch.hxx
parent8468f0beac9b792d7e2621f1a78a485ed542fb1d (diff)
Advice user to re-fetch repositories if package fetch ends up with 404 HTTP status code (GH issue #299)
Diffstat (limited to 'bpkg/fetch.hxx')
-rw-r--r--bpkg/fetch.hxx68
1 files changed, 45 insertions, 23 deletions
diff --git a/bpkg/fetch.hxx b/bpkg/fetch.hxx
index 6578f0d..daf1ffe 100644
--- a/bpkg/fetch.hxx
+++ b/bpkg/fetch.hxx
@@ -144,35 +144,57 @@ namespace bpkg
const string& user_agent = {},
const butl::url& proxy = {});
- // Similar to the above but can only be used for HTTP(S) URLs. Additionally
- // return the HTTP status code, if the underlying fetch program provides an
- // easy way to retrieve it, and 0 otherwise.
- //
- // In the former case redirect the fetch process stderr to a pipe, so that
- // depending on the returned status code the caller can either drop or dump
- // the fetch process diagnostics. May also redirect stderr in the latter
- // case for some implementation-specific reasons (to prevent the underlying
- // fetch program from interacting with the user, etc). The caller can detect
- // whether stderr is redirected by checking process::in_efd.
- //
- // In contrast to start_fetch() always fetch to stdout, which can be read by
- // the caller from the specified stream. On HTTP errors (e.g., 404) this
- // stream may contain the error description returned by the server and the
- // process may exit with 0 code.
- //
- // If the quiet argument is true, then, if stderr is redirected, minimize
- // the amount of diagnostics printed by the fetch program by only printing
- // errors. That allows the caller to read stdout and stderr streams
- // sequentially in the blocking mode by assuming that the diagnostics always
- // fits into the pipe buffer. If stderr is not redirected, then the quiet
- // argument is ignored in favor of the more informative diagnostics.
+ // Similar to the above but can only be used for fetching HTTP(S) URL to a
+ // file. Additionally return the HTTP status code, if the underlying fetch
+ // program provides an easy way to retrieve it, and 0 otherwise.
//
pair<process, uint16_t>
start_fetch_http (const common_options&,
const string& url,
+ const path& out,
+ const string& user_agent = {},
+ const butl::url& proxy = {});
+
+ // As above but fetches HTTP(S) URL to stdout, which can be read by the
+ // caller from the specified stream. On HTTP errors (e.g., 404) this stream
+ // may contain the error description returned by the server and the process
+ // may exit with 0 code.
+ //
+ // Fetch process stderr redirect mode.
+ //
+ enum class stderr_mode
+ {
+ // Don't redirect stderr.
+ //
+ pass,
+
+ // If the underlying fetch program provides an easy way to retrieve the
+ // HTTP status code, then redirect the fetch process stderr to a pipe, so
+ // that depending on the returned status code the caller can either drop
+ // or dump the fetch process diagnostics. Otherwise, may still redirect
+ // stderr for some implementation-specific reasons (to prevent the
+ // underlying fetch program from interacting with the user, etc). The
+ // caller can detect whether stderr is redirected or not by checking
+ // process::in_efd.
+ //
+ redirect,
+
+ // As above but if stderr is redirected, minimize the amount of
+ // diagnostics printed by the fetch program by only printing errors. That
+ // allows the caller to read stdout and stderr streams sequentially in the
+ // blocking mode by assuming that the diagnostics always fits into the
+ // pipe buffer. If stderr is not redirected, then ignore this mode in
+ // favor of the more informative diagnostics.
+ //
+ redirect_quiet
+ };
+
+ pair<process, uint16_t>
+ start_fetch_http (const common_options&,
+ const string& url,
ifdstream& out,
fdstream_mode out_mode,
- bool quiet,
+ stderr_mode,
const string& user_agent = {},
const butl::url& proxy = {});
}