@@ -14,7 +14,7 @@ pub struct DecodeStruct<'a, T> {
1414 pub message : & ' a mut T ,
1515 pub body : BytesMut ,
1616 pub extra_body : Option < BytesMut > ,
17- pub body_headers : Option < BodyHeader > ,
17+ pub body_headers : BodyHeader ,
1818 pub buf : & ' a mut BytesMut ,
1919}
2020
3131 }
3232 } ;
3333 let extra_body = message. get_extra_body ( ) ;
34- let body_headers = message. body_headers_as_mut ( ) . take ( ) ;
34+ let body_headers =
35+ message. body_headers_as_mut ( ) . take ( ) . unwrap_or_default ( ) ;
3536 Self {
3637 message,
3738 body_headers,
4344
4445 // TODO: implement new method in BodyHeader
4546 pub fn is_chunked_te ( & self ) -> bool {
46- self . body_headers
47- . as_ref ( )
48- . and_then ( |bh| bh. transfer_type . as_ref ( ) )
49- . map ( |tt| tt == & TransferType :: Chunked )
50- . unwrap_or ( false )
47+ self . body_headers . transfer_type == Some ( TransferType :: Chunked )
5148 }
5249
5350 pub fn chunked_to_raw ( & mut self ) {
@@ -56,33 +53,27 @@ where
5653 }
5754
5855 pub fn transfer_encoding_is_some ( & self ) -> bool {
59- self . body_headers
60- . as_ref ( )
61- . and_then ( |bh| bh. transfer_encoding . as_ref ( ) )
62- . is_some ( )
56+ self . body_headers . transfer_encoding . is_some ( )
6357 }
6458
6559 pub fn content_encoding_is_some ( & self ) -> bool {
66- self . body_headers
67- . as_ref ( )
68- . and_then ( |bh| bh. content_encoding . as_ref ( ) )
69- . is_some ( )
60+ self . body_headers . content_encoding . is_some ( )
7061 }
7162
7263 pub fn get_transfer_encoding ( & mut self ) -> Vec < EncodingInfo > {
73- self . body_headers . as_mut ( ) . unwrap ( ) . transfer_encoding . take ( ) . unwrap ( )
64+ self . body_headers . transfer_encoding . take ( ) . unwrap ( )
7465 }
7566
7667 pub fn get_content_encoding ( & mut self ) -> Vec < EncodingInfo > {
77- self . body_headers . as_mut ( ) . unwrap ( ) . content_encoding . take ( ) . unwrap ( )
68+ self . body_headers . content_encoding . take ( ) . unwrap ( )
7869 }
7970
8071 pub fn set_transfer_encoding ( & mut self , te : Vec < EncodingInfo > ) {
81- self . body_headers . as_mut ( ) . unwrap ( ) . transfer_encoding = Some ( te) ;
72+ self . body_headers . transfer_encoding = Some ( te) ;
8273 }
8374
8475 pub fn set_content_encoding ( & mut self , ce : Vec < EncodingInfo > ) {
85- self . body_headers . as_mut ( ) . unwrap ( ) . content_encoding = Some ( ce) ;
76+ self . body_headers . content_encoding = Some ( ce) ;
8677 }
8778
8879 pub fn extra_body_is_some ( & self ) -> bool {
0 commit comments