aboutsummaryrefslogtreecommitdiff
path: root/bpkg/fetch.hxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-01-10 23:33:31 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2023-01-12 13:07:30 +0300
commit01c179eed3fcfccc7cdd262742935177dfcf5106 (patch)
treeb6044897e1e752d5454f6144618ef8d46d661438 /bpkg/fetch.hxx
parent14d987674aa01cfc41f7cda4932cb5808b3ef738 (diff)
Assume git repository protocol as smart if HTTP response code is 401
Diffstat (limited to 'bpkg/fetch.hxx')
-rw-r--r--bpkg/fetch.hxx32
1 files changed, 31 insertions, 1 deletions
diff --git a/bpkg/fetch.hxx b/bpkg/fetch.hxx
index c077079..78e77a7 100644
--- a/bpkg/fetch.hxx
+++ b/bpkg/fetch.hxx
@@ -138,11 +138,41 @@ namespace bpkg
// option for details).
//
process
- start_fetch (const common_options& o,
+ start_fetch (const common_options&,
const string& url,
const path& out = {},
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.
+ //
+ // 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.
+ //
+ pair<process, uint16_t>
+ start_fetch_http (const common_options&,
+ const string& url,
+ ifdstream& out,
+ fdstream_mode out_mode,
+ bool quiet,
+ const string& user_agent = {},
+ const butl::url& proxy = {});
}
#endif // BPKG_FETCH_HXX