@@ -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,13 @@ 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
+ allow_compression : bool ,
22
25
) -> http:: Response < hyper:: Body > {
23
26
log:: info!( "handle_self_profile_processed_download({:?})" , body) ;
24
27
let mut params = body. params . clone ( ) ;
@@ -148,7 +151,18 @@ pub async fn handle_self_profile_processed_download(
148
151
hyper:: header:: HeaderValue :: from_static ( "https://profiler.firefox.com" ) ,
149
152
) ;
150
153
151
- builder. body ( hyper:: Body :: from ( output. data ) ) . unwrap ( )
154
+ if output. filename . ends_with ( "json" ) && allow_compression {
155
+ maybe_compressed_response (
156
+ builder,
157
+ output. data ,
158
+ & Some ( BrotliEncoderParams {
159
+ quality : 4 ,
160
+ ..Default :: default ( )
161
+ } ) ,
162
+ )
163
+ } else {
164
+ builder. body ( hyper:: Body :: from ( output. data ) ) . unwrap ( )
165
+ }
152
166
}
153
167
154
168
// Add query data entries to `profile` for any queries in `base_profile` which are not present in
0 commit comments