Skip to content

Commit

Permalink
refactor(sdk): Remove clone_request method
Browse files Browse the repository at this point in the history
http::Request implements Clone since http 1.0.0
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
  • Loading branch information
zecakeh authored and poljar committed Mar 3, 2025
1 parent f519522 commit cc7fb63
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions crates/matrix-sdk/src/http_client/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ pub(super) async fn send_request(

use futures_util::stream;

let request = clone_request(request);
let request = request.clone();
let request = {
let mut request = if send_progress.subscriber_count() != 0 {
let content_length = request.body().len();
Expand Down Expand Up @@ -234,17 +234,6 @@ pub(super) async fn send_request(
Ok(response_to_http_response(response).await?)
}

// Clones all request parts except the extensions which can't be cloned.
// See also https://github.com/hyperium/http/issues/395
fn clone_request(request: &http::Request<Bytes>) -> http::Request<Bytes> {
let mut builder = http::Request::builder()
.version(request.version())
.method(request.method())
.uri(request.uri());
*builder.headers_mut().unwrap() = request.headers().clone();
builder.body(request.body().clone()).unwrap()
}

struct BytesChunks {
bytes: Bytes,
size: usize,
Expand Down

0 comments on commit cc7fb63

Please sign in to comment.