File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -240,4 +240,29 @@ mod tests {
240240
241241 Ok ( ( ) )
242242 }
243+
244+ #[ test]
245+ fn head_object_omits_body_headers_from_request_and_signature ( ) -> Result < ( ) > {
246+ let region = "custom-region" . parse ( ) ?;
247+ let bucket = Bucket :: new ( "my-first-bucket" , region, fake_credentials ( ) ) ?;
248+ let request = AttoRequest :: new ( & bucket, "/my-first/path" , Command :: HeadObject ) . unwrap ( ) ;
249+
250+ let headers = request. headers ( ) . unwrap ( ) ;
251+
252+ assert ! ( !headers. contains_key( "Content-Length" ) ) ;
253+ assert ! ( !headers. contains_key( "Content-Type" ) ) ;
254+ assert ! ( headers. contains_key( "x-amz-content-sha256" ) ) ;
255+
256+ let authorization = headers. get ( "Authorization" ) . unwrap ( ) . to_str ( ) ?;
257+ let signed_headers = authorization
258+ . split ( "SignedHeaders=" )
259+ . nth ( 1 )
260+ . and_then ( |value| value. split ( ',' ) . next ( ) )
261+ . unwrap ( ) ;
262+
263+ assert ! ( !signed_headers. contains( "content-length" ) ) ;
264+ assert ! ( !signed_headers. contains( "content-type" ) ) ;
265+
266+ Ok ( ( ) )
267+ }
243268}
Original file line number Diff line number Diff line change @@ -711,6 +711,7 @@ pub trait Request {
711711 }
712712 Command :: ListObjects { .. } => { }
713713 Command :: ListObjectsV2 { .. } => { }
714+ Command :: HeadObject => { }
714715 Command :: GetObject => { }
715716 Command :: GetObjectTagging => { }
716717 Command :: GetBucketLocation => { }
You can’t perform that action at this time.
0 commit comments