@@ -28,8 +28,16 @@ public void HandleRequest(ListenerContext context, Lazy<IDatabaseContext> databa
2828 if ( ! config . UseDeflateCompression )
2929 return ;
3030
31- // If this isn't a game request or it's a resource request, don't deflate, since resource requests will be corrupted if deflated
32- if ( ! context . Uri . AbsolutePath . StartsWith ( GameEndpointAttribute . BaseRoute ) || context . Uri . AbsolutePath . StartsWith ( $ "{ GameEndpointAttribute . BaseRoute } r/") )
31+ // If this isn't a game request, it isn't necessary to do anything here.
32+ if ( ! context . Uri . AbsolutePath . StartsWith ( GameEndpointAttribute . BaseRoute ) )
33+ return ;
34+
35+ // If the request is coming through Cloudflare, tell cloudflare not to touch the data in any way
36+ if ( context . RequestHeaders [ "Cf-Ray" ] != null )
37+ context . ResponseHeaders [ "Cache-Control" ] = "no-transform" ;
38+
39+ // If this is a resource request, don't deflate because resources will be corrupted if deflated.
40+ if ( context . Uri . AbsolutePath . StartsWith ( $ "{ GameEndpointAttribute . BaseRoute } r/") )
3341 return ;
3442
3543 string ? encodings = context . RequestHeaders . Get ( "Accept-Encoding" ) ;
@@ -42,10 +50,6 @@ public void HandleRequest(ListenerContext context, Lazy<IDatabaseContext> databa
4250 context . ResponseHeaders [ "Vary" ] = "Accept-Encoding" ;
4351 context . ResponseHeaders [ "Content-Encoding" ] = "deflate" ;
4452
45- // If the request is coming through Cloudflare, tell cloudflare not to touch the data
46- if ( context . RequestHeaders [ "Cf-Ray" ] != null )
47- context . ResponseHeaders [ "Cache-Control" ] = "no-transform" ;
48-
4953 // Create a copy of our uncompressed data
5054 byte [ ] uncompressed = context . ResponseStream . ToArray ( ) ;
5155
0 commit comments