@@ -61,7 +61,7 @@ pub async fn run_server(options: Options, output: WasmBindgenOutput) -> Result<(
6161}
6262
6363fn get_router ( options : & Options , output : WasmBindgenOutput ) -> Router {
64- let WasmBindgenOutput { js, compressed_wasm , gzip_compressed_wasm, snippets, local_modules } =
64+ let WasmBindgenOutput { js, br_compressed_wasm , gzip_compressed_wasm, snippets, local_modules } =
6565 output;
6666
6767 let middleware_stack = ServiceBuilder :: new ( )
@@ -89,26 +89,22 @@ fn get_router(options: &Options, output: WasmBindgenOutput) -> Router {
8989 get_service ( ServeDir :: new ( options. directory . clone ( ) ) ) . handle_error ( internal_server_error) ;
9090
9191 let serve_wasm = |headers : HeaderMap | async move {
92- println ! ( " request headers: {:?}" , headers) ;
9392 if let Some ( accept_encoding) = headers. get ( ACCEPT_ENCODING ) {
9493 match from_utf8 ( accept_encoding. as_bytes ( ) ) {
9594 Ok ( encodings) => {
9695 let split_encodings: Vec < & str > = encodings. split ( "," ) . map ( str:: trim) . collect ( ) ;
97- println ! ( "split_encodings: {:?}" , split_encodings) ;
9896 if split_encodings. contains ( & "br" ) {
99- println ! ( "serving br compressed wasm" ) ;
10097 Ok ( (
10198 [ ( "content-encoding" , "br" ) ] ,
102- WithContentType ( "application/wasm" , compressed_wasm ) ,
99+ WithContentType ( "application/wasm" , br_compressed_wasm ) ,
103100 ) )
104101 } else if split_encodings. contains ( & "gzip" ) {
105- println ! ( "serving gzip compressed wasm" ) ;
106102 Ok ( (
107103 [ ( "content-encoding" , "gzip" ) ] ,
108104 WithContentType ( "application/wasm" , gzip_compressed_wasm) ,
109105 ) )
110106 } else {
111- println ! ( "No support for requested encoding! " ) ;
107+ tracing :: warn !( "Unsupported encoding in request for wasm.wasm " ) ;
112108 Err ( (
113109 StatusCode :: BAD_REQUEST ,
114110 format ! ( "Unsupported encoding(s): {:?}" , split_encodings) ,
@@ -229,7 +225,7 @@ mod tests {
229225 fn fake_wasm_bindgen_output ( ) -> WasmBindgenOutput {
230226 WasmBindgenOutput {
231227 js : "fake js" . to_string ( ) ,
232- compressed_wasm : FAKE_BR_COMPRESSED_WASM . to_vec ( ) ,
228+ br_compressed_wasm : FAKE_BR_COMPRESSED_WASM . to_vec ( ) ,
233229 gzip_compressed_wasm : FAKE_GZIP_COMPRESSED_WASM . to_vec ( ) ,
234230 snippets : HashMap :: < String , Vec < String > > :: new ( ) ,
235231 local_modules : HashMap :: < String , String > :: new ( ) ,
@@ -248,11 +244,8 @@ mod tests {
248244 let client = make_test_client ( ) ;
249245
250246 // Test without any supported compression
251- let mut res =
252- client. get ( "/api/wasm.wasm" ) . header ( "accept-encoding" , "deflate" ) . send ( ) . await ;
247+ let res = client. get ( "/api/wasm.wasm" ) . header ( "accept-encoding" , "deflate" ) . send ( ) . await ;
253248 assert_eq ! ( res. status( ) , StatusCode :: BAD_REQUEST ) ;
254- let result = res. chunk ( ) . await . unwrap ( ) ;
255- println ! ( "Bad Request result: {:?}" , result) ;
256249 }
257250
258251 #[ tokio:: test]
0 commit comments