11use std:: fmt;
22
33use header:: { Header , Headers } ;
4- use http:: { MessageHead , ResponseHead , Body , RawStatus } ;
4+ use http:: { MessageHead , ResponseHead , Body } ;
55use status:: StatusCode ;
66use version:: HttpVersion ;
77
@@ -10,7 +10,8 @@ pub struct Response<B = Body> {
1010 version : HttpVersion ,
1111 headers : Headers ,
1212 status : StatusCode ,
13- raw_status : RawStatus ,
13+ #[ cfg( feature = "raw_status" ) ]
14+ raw_status : :: http:: RawStatus ,
1415 body : Option < B > ,
1516}
1617
@@ -42,7 +43,8 @@ impl<B> Response<B> {
4243 /// This method is only useful when inspecting the raw subject line from
4344 /// a received response.
4445 #[ inline]
45- pub fn status_raw ( & self ) -> & RawStatus { & self . raw_status }
46+ #[ cfg( feature = "raw_status" ) ]
47+ pub fn status_raw ( & self ) -> & :: http:: RawStatus { & self . raw_status }
4648
4749 /// Set the `StatusCode` for this response.
4850 #[ inline]
@@ -101,6 +103,19 @@ impl Response<Body> {
101103 }
102104}
103105
106+ #[ cfg( not( feature = "raw_status" ) ) ]
107+ impl < B > Default for Response < B > {
108+ fn default ( ) -> Response < B > {
109+ Response :: < B > {
110+ version : Default :: default ( ) ,
111+ headers : Default :: default ( ) ,
112+ status : Default :: default ( ) ,
113+ body : None ,
114+ }
115+ }
116+ }
117+
118+ #[ cfg( feature = "raw_status" ) ]
104119impl < B > Default for Response < B > {
105120 fn default ( ) -> Response < B > {
106121 Response :: < B > {
@@ -125,6 +140,24 @@ impl fmt::Debug for Response {
125140
126141/// Constructs a response using a received ResponseHead and optional body
127142#[ inline]
143+ #[ cfg( not( feature = "raw_status" ) ) ]
144+ pub fn from_wire < B > ( incoming : ResponseHead , body : Option < B > ) -> Response < B > {
145+ let status = incoming. status ( ) ;
146+ trace ! ( "Response::new" ) ;
147+ debug ! ( "version={:?}, status={:?}" , incoming. version, status) ;
148+ debug ! ( "headers={:?}" , incoming. headers) ;
149+
150+ Response :: < B > {
151+ status : status,
152+ version : incoming. version ,
153+ headers : incoming. headers ,
154+ body : body,
155+ }
156+ }
157+
158+ /// Constructs a response using a received ResponseHead and optional body
159+ #[ inline]
160+ #[ cfg( feature = "raw_status" ) ]
128161pub fn from_wire < B > ( incoming : ResponseHead , body : Option < B > ) -> Response < B > {
129162 let status = incoming. status ( ) ;
130163 trace ! ( "Response::new" ) ;
0 commit comments