From eb998fe2190da54f066fff9daf586d219a460eaa Mon Sep 17 00:00:00 2001 From: Pasha Date: Fri, 26 Apr 2024 13:56:16 +0300 Subject: [PATCH] [feat] More clippy --- bin/main.rs | 15 ++++++++++----- src/table.rs | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/main.rs b/bin/main.rs index e5ae4a4..aadf2b7 100644 --- a/bin/main.rs +++ b/bin/main.rs @@ -267,14 +267,20 @@ async fn blobs_get( match state.iroh_node.read().await.blobs_get(hash).await { Ok(Some((reader, file_size))) => match method { Method::HEAD => Response::builder() - .header("Content-Length", file_size) - .header("Content-Type", mime_guess::mime::OCTET_STREAM.to_string()) + .header(header::CONTENT_LENGTH, file_size) + .header( + header::CONTENT_TYPE, + mime_guess::mime::OCTET_STREAM.to_string(), + ) .header("X-Iroh-Hash", hash_str) .body(Body::default()) .unwrap(), Method::GET => Response::builder() - .header("Content-Length", file_size) - .header("Content-Type", mime_guess::mime::OCTET_STREAM.to_string()) + .header(header::CONTENT_LENGTH, file_size) + .header( + header::CONTENT_TYPE, + mime_guess::mime::OCTET_STREAM.to_string(), + ) .header("X-Iroh-Hash", hash_str) .body(Body::from_stream(ReaderStream::new(reader))) .unwrap(), @@ -575,7 +581,6 @@ async fn table_get( let builder = Response::builder() .status(status_code) .header(header::ACCEPT_RANGES, "bytes") - .header(header::CACHE_CONTROL, "public,max-age=31536000,immutable") .header( header::CONTENT_TYPE, mime_guess::from_ext(&key) diff --git a/src/table.rs b/src/table.rs index 9112573..6360555 100644 --- a/src/table.rs +++ b/src/table.rs @@ -16,7 +16,7 @@ use iroh::bytes::store::{ExportMode, Map}; use iroh::bytes::Hash; use iroh::client::{Entry, LiveEvent}; use iroh::net::key::PublicKey; -use iroh::net::NodeAddr; +use iroh::net::{MagicEndpoint, NodeAddr}; use iroh::node::Node; use iroh::rpc_protocol::{BlobDownloadRequest, DownloadMode, SetTagOption, ShareMode}; use iroh::sync::store::{DownloadPolicy, Query, SortBy, SortDirection}; @@ -32,6 +32,7 @@ use std::path::PathBuf; use std::result; use std::sync::Arc; use tokio::io::AsyncRead; +use tokio_stream::StreamExt; use tokio_task_pool::Pool; use tokio_util::bytes; use tokio_util::sync::CancellationToken;