11use body_plz:: variants:: Body ;
22use bytes:: BytesMut ;
3- use header_plz:: body_headers:: BodyHeader ;
43use header_plz:: body_headers:: encoding_info:: EncodingInfo ;
54use header_plz:: body_headers:: transfer_types:: TransferType ;
65
@@ -11,11 +10,10 @@ use crate::decompress_trait::DecompressTrait;
1110#[ cfg_attr( test, derive( PartialEq ) ) ]
1211#[ derive( Debug ) ]
1312pub struct DecodeStruct < ' a , T > {
14- pub message : & ' a mut T ,
1513 pub body : BytesMut ,
16- pub extra_body : Option < BytesMut > ,
17- pub body_headers : BodyHeader ,
1814 pub buf : & ' a mut BytesMut ,
15+ pub extra_body : Option < BytesMut > ,
16+ pub message : & ' a mut T ,
1917}
2018
2119impl < ' a , T > DecodeStruct < ' a , T >
@@ -31,20 +29,20 @@ where
3129 }
3230 } ;
3331 let extra_body = message. get_extra_body ( ) ;
34- let body_headers =
35- message. body_headers_as_mut ( ) . take ( ) . unwrap_or_default ( ) ;
3632 Self {
37- message,
38- body_headers,
3933 body,
40- extra_body,
4134 buf,
35+ extra_body,
36+ message,
4237 }
4338 }
4439
4540 // TODO: implement new method in BodyHeader
4641 pub fn is_chunked_te ( & self ) -> bool {
47- self . body_headers . transfer_type == Some ( TransferType :: Chunked )
42+ self . message
43+ . body_headers ( )
44+ . map ( |b| b. transfer_type == Some ( TransferType :: Chunked ) )
45+ . unwrap_or ( false )
4846 }
4947
5048 pub fn chunked_to_raw ( & mut self ) {
@@ -53,27 +51,45 @@ where
5351 }
5452
5553 pub fn transfer_encoding_is_some ( & self ) -> bool {
56- self . body_headers . transfer_encoding . is_some ( )
54+ self . message
55+ . body_headers ( )
56+ . map ( |b| b. transfer_encoding . is_some ( ) )
57+ . unwrap_or ( false )
5758 }
5859
5960 pub fn content_encoding_is_some ( & self ) -> bool {
60- self . body_headers . content_encoding . is_some ( )
61+ self . message
62+ . body_headers ( )
63+ . map ( |b| b. content_encoding . is_some ( ) )
64+ . unwrap_or ( false )
6165 }
6266
6367 pub fn get_transfer_encoding ( & mut self ) -> Vec < EncodingInfo > {
64- self . body_headers . transfer_encoding . take ( ) . unwrap ( )
68+ self . message
69+ . body_headers_as_mut ( )
70+ . unwrap ( )
71+ . transfer_encoding
72+ . take ( )
73+ . unwrap ( )
6574 }
6675
6776 pub fn get_content_encoding ( & mut self ) -> Vec < EncodingInfo > {
68- self . body_headers . content_encoding . take ( ) . unwrap ( )
77+ self . message
78+ . body_headers_as_mut ( )
79+ . unwrap ( )
80+ . content_encoding
81+ . take ( )
82+ . unwrap ( )
6983 }
7084
7185 pub fn set_transfer_encoding ( & mut self , te : Vec < EncodingInfo > ) {
72- self . body_headers . transfer_encoding = Some ( te) ;
86+ self . message . body_headers_as_mut ( ) . unwrap ( ) . transfer_encoding =
87+ Some ( te) ;
7388 }
7489
7590 pub fn set_content_encoding ( & mut self , ce : Vec < EncodingInfo > ) {
76- self . body_headers . content_encoding = Some ( ce) ;
91+ self . message . body_headers_as_mut ( ) . unwrap ( ) . content_encoding =
92+ Some ( ce) ;
7793 }
7894
7995 pub fn extra_body_is_some ( & self ) -> bool {
0 commit comments