Skip to content

Commit

Permalink
simply bad status error message
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay committed Mar 16, 2023
1 parent 9657422 commit 2ddda25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/dlm_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub enum DlmError {
ResponseBodyError,
#[error("deadline elapsed timeout")]
DeadLineElapsedTimeout,
#[error("response status not success - {message:?}")]
ResponseStatusNotSuccess { message: String },
#[error("response status not success - {status_code:?}")]
ResponseStatusNotSuccess { status_code: String },
#[error("URL decode error - {message:?}")]
UrlDecodeError { message: String },
#[error("standard I/O error - {e}")]
Expand Down
12 changes: 6 additions & 6 deletions src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ pub async fn download_link(
let url = file_link.url.as_str();
let head_result = client.head(url).send().await?;
if !head_result.status().is_success() {
let message = format!("{} {}", url, head_result.status());
Err(DlmError::ResponseStatusNotSuccess { message })
let status_code = format!("{}", head_result.status());
Err(DlmError::ResponseStatusNotSuccess { status_code })
} else {
let (content_length, accept_ranges) =
try_hard_to_extract_headers(head_result.headers(), url, client).await?;
Expand Down Expand Up @@ -92,8 +92,8 @@ pub async fn download_link(
// initiate file download
let mut dl_response = request.send().await?;
if !dl_response.status().is_success() {
let message = format!("{} {}", url, dl_response.status());
Err(DlmError::ResponseStatusNotSuccess { message })
let status_code = format!("{}", head_result.status());
Err(DlmError::ResponseStatusNotSuccess { status_code })
} else {
// incremental save chunk by chunk into part file
let chunk_timeout = Duration::from_secs(60);
Expand Down Expand Up @@ -258,8 +258,8 @@ async fn compute_filename_from_disposition_header(
) -> Result<Option<String>, DlmError> {
let head_result = client.head(url).send().await?;
if !head_result.status().is_success() {
let message = format!("{} {}", url, head_result.status());
Err(DlmError::ResponseStatusNotSuccess { message })
let status_code = format!("{}", head_result.status());
Err(DlmError::ResponseStatusNotSuccess { status_code })
} else {
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Disposition#as_a_response_header_for_the_main_body
let content_disposition = content_disposition_value(head_result.headers());
Expand Down

0 comments on commit 2ddda25

Please sign in to comment.