1- use std:: error:: Error ;
2- use std:: ffi:: c_void;
3- use std:: fmt;
4- use std:: str:: FromStr ;
1+ use core:: ffi:: c_void;
2+ use core:: fmt;
3+ use core:: str:: FromStr ;
54
65use crate :: core:: * ;
76use crate :: ffi:: * ;
@@ -30,7 +29,7 @@ macro_rules! http_subrequest_handler {
3029 ( $name: ident, $handler: expr ) => {
3130 unsafe extern "C" fn $name(
3231 r: * mut $crate:: ffi:: ngx_http_request_t,
33- data: * mut :: std :: ffi:: c_void,
32+ data: * mut :: core :: ffi:: c_void,
3433 rc: $crate:: ffi:: ngx_int_t,
3534 ) -> $crate:: ffi:: ngx_int_t {
3635 $handler( r, data, rc)
@@ -116,7 +115,7 @@ impl Request {
116115 /// Is this the main request (as opposed to a subrequest)?
117116 pub fn is_main ( & self ) -> bool {
118117 let main = self . 0 . main . cast ( ) ;
119- std :: ptr:: eq ( self , main)
118+ core :: ptr:: eq ( self , main)
120119 }
121120
122121 /// Request pool.
@@ -263,6 +262,7 @@ impl Request {
263262 /// Add header to the `headers_in` object.
264263 ///
265264 /// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
265+ #[ cfg( feature = "alloc" ) ]
266266 pub fn add_header_in ( & mut self , key : & str , value : & str ) -> Option < ( ) > {
267267 let table: * mut ngx_table_elt_t = unsafe { ngx_list_push ( & mut self . 0 . headers_in . headers ) as _ } ;
268268 unsafe { add_to_ngx_table ( table, self . 0 . pool , key, value) }
@@ -271,6 +271,7 @@ impl Request {
271271 /// Add header to the `headers_out` object.
272272 ///
273273 /// See <https://nginx.org/en/docs/dev/development_guide.html#http_request>
274+ #[ cfg( feature = "alloc" ) ]
274275 pub fn add_header_out ( & mut self , key : & str , value : & str ) -> Option < ( ) > {
275276 let table: * mut ngx_table_elt_t = unsafe { ngx_list_push ( & mut self . 0 . headers_out . headers ) as _ } ;
276277 unsafe { add_to_ngx_table ( table, self . 0 . pool , key, value) }
@@ -337,7 +338,7 @@ impl Request {
337338 ngx_http_internal_redirect (
338339 ( self as * const Request as * mut Request ) . cast ( ) ,
339340 uri_ptr,
340- std :: ptr:: null_mut ( ) ,
341+ core :: ptr:: null_mut ( ) ,
341342 ) ;
342343 }
343344 }
@@ -354,7 +355,7 @@ impl Request {
354355 let uri_ptr = unsafe { & mut ngx_str_t:: from_str ( self . 0 . pool , uri) as * mut _ } ;
355356 // -------------
356357 // allocate memory and set values for ngx_http_post_subrequest_t
357- let sub_ptr = self . pool ( ) . alloc ( std :: mem:: size_of :: < ngx_http_post_subrequest_t > ( ) ) ;
358+ let sub_ptr = self . pool ( ) . alloc ( core :: mem:: size_of :: < ngx_http_post_subrequest_t > ( ) ) ;
358359
359360 // assert!(sub_ptr.is_null());
360361 let post_subreq = sub_ptr as * const ngx_http_post_subrequest_t as * mut ngx_http_post_subrequest_t ;
@@ -364,12 +365,12 @@ impl Request {
364365 }
365366 // -------------
366367
367- let mut psr: * mut ngx_http_request_t = std :: ptr:: null_mut ( ) ;
368+ let mut psr: * mut ngx_http_request_t = core :: ptr:: null_mut ( ) ;
368369 let r = unsafe {
369370 ngx_http_subrequest (
370371 ( self as * const Request as * mut Request ) . cast ( ) ,
371372 uri_ptr,
372- std :: ptr:: null_mut ( ) ,
373+ core :: ptr:: null_mut ( ) ,
373374 & mut psr as * mut _ ,
374375 sub_ptr as * mut _ ,
375376 NGX_HTTP_SUBREQUEST_WAITED as _ ,
@@ -383,7 +384,7 @@ impl Request {
383384 * allocate fake request body to avoid attempts to read it and to make
384385 * sure real body file (if already read) won't be closed by upstream
385386 */
386- sr. request_body = self . pool ( ) . alloc ( std :: mem:: size_of :: < ngx_http_request_body_t > ( ) ) as * mut _ ;
387+ sr. request_body = self . pool ( ) . alloc ( core :: mem:: size_of :: < ngx_http_request_body_t > ( ) ) as * mut _ ;
387388
388389 if sr. request_body . is_null ( ) {
389390 return Status :: NGX_ERROR ;
@@ -422,7 +423,7 @@ impl fmt::Debug for Request {
422423
423424/// Iterator for [`ngx_list_t`] types.
424425///
425- /// Implementes the std ::iter::Iterator trait.
426+ /// Implementes the core ::iter::Iterator trait.
426427pub struct NgxListIterator {
427428 done : bool ,
428429 part : * const ngx_list_part_t ,
@@ -711,7 +712,8 @@ impl fmt::Display for InvalidMethod {
711712 }
712713}
713714
714- impl Error for InvalidMethod { }
715+ #[ cfg( feature = "std" ) ]
716+ impl std:: error:: Error for InvalidMethod { }
715717
716718#[ derive( Clone , PartialEq , Eq , Hash ) ]
717719enum MethodInner {
0 commit comments