From 59a86f5ea854475b365679bd8d7604e50b724783 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 20 Jan 2023 14:44:54 +0300 Subject: Fix unexpected 'unable to read HTTP response status line' fetch error --- bpkg/fetch-git.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'bpkg/fetch-git.cxx') 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. -- cgit v1.1