1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-30 16:34:26 +02:00

migrate to brotli crate

This commit is contained in:
Rob Ede
2022-01-21 21:16:23 +00:00
parent 0669ed0f06
commit ad7e3c06e7
7 changed files with 35 additions and 28 deletions

View File

@ -4,7 +4,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
use brotli2::write::BrotliEncoder;
use brotli::CompressorWriter as BrotliEncoder;
use bytes::Bytes;
use flate2::read::GzDecoder;
use flate2::write::GzEncoder;
@ -506,9 +506,10 @@ async fn test_client_gzip_encoding_large_random() {
async fn test_client_brotli_encoding() {
let srv = test::start(|| {
App::new().service(web::resource("/").route(web::to(|data: Bytes| {
let mut e = BrotliEncoder::new(Vec::new(), 5);
let mut e = BrotliEncoder::new(Vec::new(), 8096, 5, 22);
e.write_all(&data).unwrap();
let data = e.finish().unwrap();
e.flush().unwrap();
let data = e.into_inner();
HttpResponse::Ok()
.header("content-encoding", "br")
.body(data)
@ -533,9 +534,9 @@ async fn test_client_brotli_encoding_large_random() {
let srv = test::start(|| {
App::new().service(web::resource("/").route(web::to(|data: Bytes| {
let mut e = BrotliEncoder::new(Vec::new(), 5);
let mut e = BrotliEncoder::new(Vec::new(), 8096, 5, 22);
e.write_all(&data).unwrap();
let data = e.finish().unwrap();
let data = e.into_inner();
HttpResponse::Ok()
.header("content-encoding", "br")
.body(data)