mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 21:04:27 +01:00
Fix formatting and shaving lints
This commit is contained in:
parent
b69f8d67c3
commit
2dce44f4c1
@ -1,9 +1,9 @@
|
|||||||
use actix_http::header::TryIntoHeaderPair;
|
use actix_http::header::TryIntoHeaderPair;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
use flate2::read::{GzDecoder, ZlibDecoder};
|
||||||
use flate2::write::{GzEncoder, ZlibEncoder};
|
use flate2::write::{GzEncoder, ZlibEncoder};
|
||||||
use flate2::Compression;
|
use flate2::Compression;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use flate2::read::{GzDecoder, ZlibDecoder};
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum Encoder {
|
pub enum Encoder {
|
||||||
@ -50,22 +50,22 @@ impl Encoder {
|
|||||||
GzDecoder::new(input.as_ref())
|
GzDecoder::new(input.as_ref())
|
||||||
.read_to_end(&mut buffer)
|
.read_to_end(&mut buffer)
|
||||||
.expect("Invalid gzip stream");
|
.expect("Invalid gzip stream");
|
||||||
},
|
}
|
||||||
Self::Deflate => {
|
Self::Deflate => {
|
||||||
ZlibDecoder::new(input.as_ref())
|
ZlibDecoder::new(input.as_ref())
|
||||||
.read_to_end(&mut buffer)
|
.read_to_end(&mut buffer)
|
||||||
.expect("Invalid zlib stream");
|
.expect("Invalid zlib stream");
|
||||||
},
|
}
|
||||||
Self::Plain => {
|
Self::Plain => {
|
||||||
buffer
|
buffer
|
||||||
.write(input.as_ref())
|
.write_all(input.as_ref())
|
||||||
.expect("Unexpected memory copying issue");
|
.expect("Unexpected memory copying issue");
|
||||||
},
|
}
|
||||||
Self::Brotli => {
|
Self::Brotli => {
|
||||||
brotli::Decompressor::new(input.as_ref(), 4096 )
|
brotli::Decompressor::new(input.as_ref(), 4096)
|
||||||
.read_to_end(&mut buffer)
|
.read_to_end(&mut buffer)
|
||||||
.expect("Invalid brotli stream");
|
.expect("Invalid brotli stream");
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
buffer
|
buffer
|
||||||
}
|
}
|
||||||
|
@ -174,13 +174,10 @@ async fn get_all_documents_no_options_with_response_compression() {
|
|||||||
server.service.options,
|
server.service.options,
|
||||||
analytics::MockAnalytics::new(&server.service.options).0
|
analytics::MockAnalytics::new(&server.service.options).0
|
||||||
))
|
))
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let req = test::TestRequest::get()
|
let req = test::TestRequest::get()
|
||||||
.uri(&format!(
|
.uri(&format!("/indexes/{}/documents?", urlencode(index_uid)))
|
||||||
"/indexes/{}/documents?",
|
|
||||||
urlencode(index_uid.as_ref())
|
|
||||||
))
|
|
||||||
.insert_header((ACCEPT_ENCODING, "gzip"))
|
.insert_header((ACCEPT_ENCODING, "gzip"))
|
||||||
.to_request();
|
.to_request();
|
||||||
|
|
||||||
@ -191,7 +188,7 @@ async fn get_all_documents_no_options_with_response_compression() {
|
|||||||
let bytes = test::read_body(res).await;
|
let bytes = test::read_body(res).await;
|
||||||
let decoded = Encoder::Gzip.decode(bytes);
|
let decoded = Encoder::Gzip.decode(bytes);
|
||||||
let parsed_response =
|
let parsed_response =
|
||||||
serde_json::from_slice::<Value>(&decoded.into().as_ref()).expect("Expecting valid json");
|
serde_json::from_slice::<Value>(decoded.into().as_ref()).expect("Expecting valid json");
|
||||||
|
|
||||||
let arr = parsed_response["results"].as_array().unwrap();
|
let arr = parsed_response["results"].as_array().unwrap();
|
||||||
assert_eq!(arr.len(), 20);
|
assert_eq!(arr.len(), 20);
|
||||||
|
@ -72,7 +72,7 @@ async fn create_index_with_gzip_encoded_request_and_receiving_brotli_encoded_res
|
|||||||
let bytes = test::read_body(res).await;
|
let bytes = test::read_body(res).await;
|
||||||
let decoded = Encoder::Brotli.decode(bytes);
|
let decoded = Encoder::Brotli.decode(bytes);
|
||||||
let parsed_response =
|
let parsed_response =
|
||||||
serde_json::from_slice::<Value>(&decoded.into().as_ref()).expect("Expecting valid json");
|
serde_json::from_slice::<Value>(decoded.into().as_ref()).expect("Expecting valid json");
|
||||||
|
|
||||||
assert_eq!(parsed_response["taskUid"], 0);
|
assert_eq!(parsed_response["taskUid"], 0);
|
||||||
assert_eq!(parsed_response["indexUid"], "test");
|
assert_eq!(parsed_response["indexUid"], "test");
|
||||||
|
Loading…
Reference in New Issue
Block a user