@@ -3,6 +3,7 @@ use std::io::Read;
33use std:: sync:: Arc ;
44use std:: time:: Instant ;
55
6+ use brotli:: enc:: BrotliEncoderParams ;
67use bytes:: Buf ;
78use database:: selector;
89use database:: ArtifactId ;
@@ -14,11 +15,13 @@ use crate::api::self_profile::ArtifactSizeDelta;
1415use crate :: api:: { self_profile, self_profile_processed, self_profile_raw, ServerResult } ;
1516use crate :: load:: SiteCtxt ;
1617use crate :: self_profile:: { get_or_download_self_profile, get_self_profile_raw_data} ;
18+ use crate :: server:: maybe_compressed_response;
1719use crate :: server:: { Response , ResponseHeaders } ;
1820
1921pub async fn handle_self_profile_processed_download (
2022 body : self_profile_processed:: Request ,
2123 ctxt : & SiteCtxt ,
24+ allow_compression : bool ,
2225) -> http:: Response < hyper:: Body > {
2326 log:: info!( "handle_self_profile_processed_download({:?})" , body) ;
2427 let mut params = body. params . clone ( ) ;
@@ -148,7 +151,18 @@ pub async fn handle_self_profile_processed_download(
148151 hyper:: header:: HeaderValue :: from_static ( "https://profiler.firefox.com" ) ,
149152 ) ;
150153
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+ }
152166}
153167
154168// Add query data entries to `profile` for any queries in `base_profile` which are not present in
0 commit comments