Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return response of initial HEAD request #1

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl AsyncHttpRangeReader {
CheckSupportMethod::NegativeRangeRequest(initial_chunk_size) => {
Self::new_tail_request(client, url, initial_chunk_size).await
baszalmstra marked this conversation as resolved.
Show resolved Hide resolved
}
CheckSupportMethod::Head => Self::new_head(client, url).await,
CheckSupportMethod::Head => Ok(Self::new_head(client, url).await?.0),
}
}

Expand Down Expand Up @@ -204,10 +204,10 @@ impl AsyncHttpRangeReader {
})
}

async fn new_head(
pub async fn new_head(
client: reqwest::Client,
url: reqwest::Url,
) -> Result<Self, AsyncHttpRangeReaderError> {
) -> Result<(Self, reqwest::Response), AsyncHttpRangeReaderError> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it makes sense to only return the headers of the request?

// Perform a HEAD request to get the content-length.
let head_response = client
.head(url.clone())
Expand Down Expand Up @@ -264,7 +264,7 @@ impl AsyncHttpRangeReader {
// Configure the initial state of the streamer.
let streamer_state = StreamerState::default();

Ok(Self {
let reader = Self {
len: memory_map_slice.len() as u64,
inner: Mutex::new(Inner {
data: memory_map_slice,
Expand All @@ -275,7 +275,8 @@ impl AsyncHttpRangeReader {
request_tx,
poll_request_tx: None,
}),
})
};
Ok((reader, head_response))
}

/// Returns the ranges that this instance actually performed HTTP requests for.
Expand Down