@@ -3,6 +3,7 @@ use std::io::Read;
3
3
use std:: sync:: Arc ;
4
4
use std:: time:: Instant ;
5
5
6
+ use brotli:: enc:: BrotliEncoderParams ;
6
7
use bytes:: Buf ;
7
8
use database:: selector;
8
9
use database:: ArtifactId ;
@@ -14,11 +15,14 @@ use crate::api::self_profile::ArtifactSizeDelta;
14
15
use crate :: api:: { self_profile, self_profile_processed, self_profile_raw, ServerResult } ;
15
16
use crate :: load:: SiteCtxt ;
16
17
use crate :: self_profile:: { get_or_download_self_profile, get_self_profile_raw_data} ;
18
+ use crate :: server:: maybe_compressed_response;
17
19
use crate :: server:: { Response , ResponseHeaders } ;
18
20
19
21
pub async fn handle_self_profile_processed_download (
20
22
body : self_profile_processed:: Request ,
21
23
ctxt : & SiteCtxt ,
24
+ // compression: &Option<BrotliEncoderParams>,
25
+ allow_compression : bool ,
22
26
) -> http:: Response < hyper:: Body > {
23
27
log:: info!( "handle_self_profile_processed_download({:?})" , body) ;
24
28
let mut params = body. params . clone ( ) ;
@@ -148,7 +152,19 @@ pub async fn handle_self_profile_processed_download(
148
152
hyper:: header:: HeaderValue :: from_static ( "https://profiler.firefox.com" ) ,
149
153
) ;
150
154
151
- builder. body ( hyper:: Body :: from ( output. data ) ) . unwrap ( )
155
+ if output. filename . starts_with ( "json" ) && allow_compression {
156
+ // maybe_compressed_response(builder, output.data, compression)
157
+ maybe_compressed_response (
158
+ builder,
159
+ output. data ,
160
+ & Some ( BrotliEncoderParams {
161
+ quality : 5 ,
162
+ ..Default :: default ( )
163
+ } ) ,
164
+ )
165
+ } else {
166
+ builder. body ( hyper:: Body :: from ( output. data ) ) . unwrap ( )
167
+ }
152
168
}
153
169
154
170
// Add query data entries to `profile` for any queries in `base_profile` which are not present in
0 commit comments