@@ -9,7 +9,7 @@ use futures::Future;
99use futures:: stream:: Stream ;
1010
1111use hyper:: { Client , Method , Request , StatusCode , Uri } ;
12- use hyper:: header:: { Cookie , UserAgent } ;
12+ use hyper:: header:: { Cookie , UserAgent , AcceptEncoding , Encoding , qitem } ;
1313use hyper_tls:: HttpsConnector ;
1414
1515use tokio_core:: reactor:: Core ;
@@ -40,6 +40,7 @@ pub struct Loader {
4040 cookie : Cookie ,
4141 captcha_string : String ,
4242 keep_alive : bool ,
43+ gzip : bool ,
4344 delay : u64 ,
4445}
4546
@@ -95,6 +96,7 @@ impl Loader {
9596 user_agent : user_agent,
9697 cookie : cookie_jar,
9798 keep_alive : args. keep_alive ,
99+ gzip : args. gzip ,
98100 delay : args. delay ,
99101 captcha_string : args. captcha_string . to_string ( ) ,
100102 } ) )
@@ -158,6 +160,13 @@ impl Loader {
158160 let mut req: Request = Request :: new ( Method :: Get , cache_resource. uri . clone ( ) ) ;
159161 req. headers_mut ( ) . set ( self . user_agent . clone ( ) ) ;
160162 req. headers_mut ( ) . set ( self . cookie . clone ( ) ) ;
163+ if self . gzip {
164+ req. headers_mut ( ) . set ( AcceptEncoding ( vec ! [
165+ qitem( Encoding :: Brotli ) ,
166+ qitem( Encoding :: Gzip ) ,
167+ qitem( Encoding :: Deflate ) ,
168+ ] ) ) ;
169+ }
161170
162171 let task = client. request ( req) . and_then ( |res| {
163172 cache_resource. cache_status = match res. headers ( ) . get :: < XCacheStatus > ( ) {
0 commit comments