1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-07 16:15:32 +02:00

print url

This commit is contained in:
Jan Lukas Gernert 2023-07-28 07:09:50 +02:00
parent 40f065d9cd
commit eb1bfdbca0

View file

@ -1193,7 +1193,7 @@ impl Util {
let status_code = response.status();
if !status_code.is_success() {
log::warn!("response: {status_code}");
log::warn!("response: {status_code} ({})", response.url());
return Err(ImageDownloadError::Http);
}
@ -1206,16 +1206,19 @@ impl Util {
}
pub fn get_content_type(response: &Response) -> Result<String, ImageDownloadError> {
if response.status().is_success() {
let status_code = response.status();
if !status_code.is_success() {
log::warn!("response: {status_code} ({})", response.url());
return Err(ImageDownloadError::Http);
}
response
.headers()
.get(CONTENT_TYPE)
.and_then(|val| val.to_str().ok())
.map(|val| val.to_string())
.ok_or(ImageDownloadError::ContentType)
} else {
Err(ImageDownloadError::ContentType)
}
}
}