refactor: reduce allocations when using fixed HTTP methods
Diff
src/exts/http.rs | 2 +-
src/static_files.rs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
@@ -3,7 +3,7 @@
use hyper::Method;
pub const HTTP_SUPPORTED_METHODS: [Method; 3] = [Method::OPTIONS, Method::HEAD, Method::GET];
pub const HTTP_SUPPORTED_METHODS: &[Method; 3] = &[Method::OPTIONS, Method::HEAD, Method::GET];
pub trait MethodExt {
@@ -94,7 +94,7 @@ pub async fn handle<'a>(opts: &HandleOpts<'a>) -> Result<(Response<Body>, bool),
let mut resp = Response::new(Body::empty());
*resp.status_mut() = StatusCode::NO_CONTENT;
resp.headers_mut()
.typed_insert(headers::Allow::from_iter(HTTP_SUPPORTED_METHODS));
.typed_insert(headers::Allow::from_iter(HTTP_SUPPORTED_METHODS.clone()));
resp.headers_mut().typed_insert(AcceptRanges::bytes());
return Ok((resp, is_precompressed));