aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuentin <quentin@deuxfleurs.fr>2020-11-21 17:58:14 +0100
committerQuentin <quentin@deuxfleurs.fr>2020-11-21 17:58:14 +0100
commitb7a377308bbcbb7285a5b11cdcb07361eff93a28 (patch)
treeefcb5047636ec32a31ec0b552e0bfe6b5d3d3f8f /src
parenta88fd49f71844f04013970a678201a65ab89fb19 (diff)
downloadgarage-b7a377308bbcbb7285a5b11cdcb07361eff93a28.tar.gz
garage-b7a377308bbcbb7285a5b11cdcb07361eff93a28.zip
Handle HEAD
Diffstat (limited to 'src')
-rw-r--r--src/web/web_server.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/web/web_server.rs b/src/web/web_server.rs
index 4f79a9ec..f8a5cd14 100644
--- a/src/web/web_server.rs
+++ b/src/web/web_server.rs
@@ -6,13 +6,13 @@ use hyper::{
header::HOST,
server::conn::AddrStream,
service::{make_service_fn, service_fn},
- Body, Request, Response, Server,
+ Body, Method, Request, Response, Server,
};
use idna::domain_to_unicode;
use crate::error::*;
-use garage_api::s3_get::handle_get;
+use garage_api::s3_get::{handle_get, handle_head};
use garage_model::garage::Garage;
use garage_util::error::Error as GarageError;
@@ -83,9 +83,13 @@ async fn serve_file(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<
info!("Selected bucket: \"{}\", selected key: \"{}\"", bucket, key);
- let r = handle_get(garage, &req, bucket, &key).await?;
+ let res = match req.method() {
+ &Method::HEAD => handle_head(garage, &bucket, &key).await?,
+ &Method::GET => handle_get(garage, &req, bucket, &key).await?,
+ _ => return Err(Error::BadRequest(format!("HTTP method not supported"))),
+ };
- Ok(r)
+ Ok(res)
}
/// Extract host from the authority section given by the HTTP host header