@@ -19,19 +19,21 @@ impl HttpModule for Module {
19
19
}
20
20
21
21
unsafe extern "C" fn postconfiguration ( cf : * mut ngx_conf_t ) -> ngx_int_t {
22
- // SAFETY: this function is called with non-NULL cf always
23
- let cf = & mut * cf;
24
- let cmcf = NgxHttpCoreModule :: main_conf_mut ( cf) . expect ( "http core main conf" ) ;
25
-
26
- let h = ngx_array_push (
27
- & mut cmcf. phases [ ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE as usize ] . handlers ,
28
- ) as * mut ngx_http_handler_pt ;
29
- if h. is_null ( ) {
30
- return core:: Status :: NGX_ERROR . into ( ) ;
22
+ unsafe {
23
+ // SAFETY: this function is called with non-NULL cf always
24
+ let cf = & mut * cf;
25
+ let cmcf = NgxHttpCoreModule :: main_conf_mut ( cf) . expect ( "http core main conf" ) ;
26
+
27
+ let h = ngx_array_push (
28
+ & mut cmcf. phases [ ngx_http_phases_NGX_HTTP_PRECONTENT_PHASE as usize ] . handlers ,
29
+ ) as * mut ngx_http_handler_pt ;
30
+ if h. is_null ( ) {
31
+ return core:: Status :: NGX_ERROR . into ( ) ;
32
+ }
33
+ // set an phase handler
34
+ * h = Some ( awssigv4_header_handler) ;
35
+ core:: Status :: NGX_OK . into ( )
31
36
}
32
- // set an phase handler
33
- * h = Some ( awssigv4_header_handler) ;
34
- core:: Status :: NGX_OK . into ( )
35
37
}
36
38
}
37
39
@@ -298,10 +300,13 @@ http_request_handler!(awssigv4_header_handler, |request: &mut Request| {
298
300
for ( name, value) in request. headers_in_iterator( ) {
299
301
if let Ok ( name) = name. to_str( ) {
300
302
if name. to_lowercase( ) == "host" {
301
- if let Ok ( value) = http:: HeaderValue :: from_bytes( value. as_bytes( ) ) {
302
- headers. insert( http:: header:: HOST , value) ;
303
- } else {
304
- return core:: Status :: NGX_DECLINED ;
303
+ match http:: HeaderValue :: from_bytes( value. as_bytes( ) ) {
304
+ Ok ( value) => {
305
+ headers. insert( http:: header:: HOST , value) ;
306
+ }
307
+ _ => {
308
+ return core:: Status :: NGX_DECLINED ;
309
+ }
305
310
}
306
311
}
307
312
} else {
0 commit comments