aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-27 10:12:15 -0600
committerMelody Horn <melody@boringcactus.com>2021-03-27 10:12:15 -0600
commit3ef3351e6c9d74aeafe8d185f27ce078f166f363 (patch)
tree091904d13c5e402cefdfcf2eb5533b1697c1f3e4
parente0f4483ff90e85b841a3cd4748811fcf3738d495 (diff)
downloadwebget-3ef3351e6c9d74aeafe8d185f27ce078f166f363.tar.gz
webget-3ef3351e6c9d74aeafe8d185f27ce078f166f363.zip
print response on failure status code
-rw-r--r--src/download.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/download.rs b/src/download.rs
index 82bb302..fa99ea5 100644
--- a/src/download.rs
+++ b/src/download.rs
@@ -36,7 +36,10 @@ pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> {
response = client.get(location).await?;
}
if !response.status().is_success() {
- bail!("non-success response code {} in URL {}", response.status(), url);
+ let status = response.status();
+ let body = hyper::body::to_bytes(response.into_body()).await?;
+ let body = String::from_utf8_lossy(&body);
+ bail!("non-success response code {} in URL {}:\n{}\n", status, url, body);
}
let output_file_path = if let Some(path) = output_file_path {