diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2023-01-20 14:44:54 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2023-01-23 14:38:11 +0300 |
commit | 59a86f5ea854475b365679bd8d7604e50b724783 (patch) | |
tree | c04573b6b75783c1751c3e45e81e7ee596c04e59 /bpkg/fetch-git.cxx | |
parent | 8085f0f8ae4520fcd9ac9bf1ec9ac7ec5f1aad90 (diff) |
Fix unexpected 'unable to read HTTP response status line' fetch error
Diffstat (limited to 'bpkg/fetch-git.cxx')
-rw-r--r-- | bpkg/fetch-git.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/bpkg/fetch-git.cxx b/bpkg/fetch-git.cxx index 4b1a242..f3c6355 100644 --- a/bpkg/fetch-git.cxx +++ b/bpkg/fetch-git.cxx @@ -654,6 +654,31 @@ namespace bpkg return capabilities::smart; } + // Fail on any other HTTP error (e.g., 404). In the case of a success + // code other than 200 (e.g. 204 (No Content)) just let the capabilities + // detection to take its course. + // + if (ps.second != 0 && (ps.second < 200 || ps.second >= 300)) + { + // Note that we don't care about the process exit code here (see above + // for the reasoning). + // + is.close (); + + // Dump the potentially redirected process stderr stream content since + // it may be helpful to the user. + // + // Note, however, that we don't know if it really contains the error + // description since the fetch program may even exit successfully (see + // start_fetch_http() for details). Thus, we additionally print the + // HTTP status code in the diagnostics. + // + dump_stderr (); + + fail << "unable to fetch " << url << + info << "HTTP status code " << ps.second << endg; + } + string l; getline (is, l); // Is empty if no refs returned by the dumb server. |