mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
Replace flate2-xxx features with compress
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "awc"
|
||||
version = "1.0.0-alpha.4"
|
||||
version = "1.0.0"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix http client."
|
||||
readme = "README.md"
|
||||
@ -12,19 +12,17 @@ categories = ["network-programming", "asynchronous",
|
||||
"web-programming::http-client",
|
||||
"web-programming::websocket"]
|
||||
license = "MIT/Apache-2.0"
|
||||
exclude = [".gitignore", ".travis.yml", ".cargo/config", "appveyor.yml"]
|
||||
edition = "2018"
|
||||
workspace = ".."
|
||||
|
||||
[lib]
|
||||
name = "awc"
|
||||
path = "src/lib.rs"
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["openssl", "rustls", "flate2-zlib"]
|
||||
features = ["openssl", "rustls", "compress"]
|
||||
|
||||
[features]
|
||||
default = ["flate2-zlib"]
|
||||
default = ["compress"]
|
||||
|
||||
# openssl
|
||||
openssl = ["open-ssl", "actix-http/openssl"]
|
||||
@ -32,16 +30,13 @@ openssl = ["open-ssl", "actix-http/openssl"]
|
||||
# rustls
|
||||
rustls = ["rust-tls", "actix-http/rustls"]
|
||||
|
||||
# miniz-sys backend for flate2 crate
|
||||
flate2-zlib = ["actix-http/flate2-zlib"]
|
||||
|
||||
# rust backend for flate2 crate
|
||||
flate2-rust = ["actix-http/flate2-rust"]
|
||||
# content-encoding support
|
||||
compress = ["actix-http/compress"]
|
||||
|
||||
[dependencies]
|
||||
actix-codec = "0.2.0"
|
||||
actix-service = "1.0.0"
|
||||
actix-http = "1.0.0-alpha.4"
|
||||
actix-http = "1.0.0"
|
||||
actix-rt = "1.0.0"
|
||||
|
||||
base64 = "0.11"
|
||||
@ -61,12 +56,12 @@ rust-tls = { version = "0.16.0", package="rustls", optional = true, features = [
|
||||
[dev-dependencies]
|
||||
actix-connect = { version = "1.0.0", features=["openssl"] }
|
||||
actix-web = { version = "2.0.0-alpha.3", features=["openssl"] }
|
||||
actix-http = { version = "1.0.0-alpha.4", features=["openssl"] }
|
||||
actix-http = { version = "1.0.0", features=["openssl"] }
|
||||
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
||||
actix-utils = "1.0.0"
|
||||
actix-server = "1.0.0"
|
||||
actix-tls = { version = "1.0.0", features=["openssl", "rustls"] }
|
||||
brotli = "3.3.0"
|
||||
flate2 = { version="1.0.2" }
|
||||
flate2 = "1.0.13"
|
||||
env_logger = "0.6"
|
||||
webpki = { version = "0.21" }
|
||||
webpki = "0.21"
|
||||
|
@ -3,26 +3,17 @@ use std::io;
|
||||
use actix_codec::Framed;
|
||||
use actix_http::{body::BodySize, h1, ws, Error, HttpService, Request, Response};
|
||||
use actix_http_test::TestServer;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use bytes::Bytes;
|
||||
use futures::future::ok;
|
||||
use futures::{SinkExt, StreamExt};
|
||||
|
||||
async fn ws_service(req: ws::Frame) -> Result<ws::Message, io::Error> {
|
||||
match req {
|
||||
ws::Frame::Ping(msg) => Ok(ws::Message::Pong(msg)),
|
||||
ws::Frame::Text(text) => {
|
||||
let text = if let Some(pl) = text {
|
||||
String::from_utf8(Vec::from(pl.as_ref())).unwrap()
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
Ok(ws::Message::Text(text))
|
||||
}
|
||||
ws::Frame::Binary(bin) => Ok(ws::Message::Binary(
|
||||
bin.map(|e| e.freeze())
|
||||
.unwrap_or_else(|| Bytes::from(""))
|
||||
.into(),
|
||||
ws::Frame::Text(text) => Ok(ws::Message::Text(
|
||||
String::from_utf8(Vec::from(text.as_ref())).unwrap(),
|
||||
)),
|
||||
ws::Frame::Binary(bin) => Ok(ws::Message::Binary(bin)),
|
||||
ws::Frame::Close(reason) => Ok(ws::Message::Close(reason)),
|
||||
_ => Ok(ws::Message::Close(None)),
|
||||
}
|
||||
@ -56,14 +47,14 @@ async fn test_simple() {
|
||||
.await
|
||||
.unwrap();
|
||||
let item = framed.next().await.unwrap().unwrap();
|
||||
assert_eq!(item, ws::Frame::Text(Some(BytesMut::from("text"))));
|
||||
assert_eq!(item, ws::Frame::Text(Bytes::from_static(b"text")));
|
||||
|
||||
framed
|
||||
.send(ws::Message::Binary("text".into()))
|
||||
.await
|
||||
.unwrap();
|
||||
let item = framed.next().await.unwrap().unwrap();
|
||||
assert_eq!(item, ws::Frame::Binary(Some(BytesMut::from(&b"text"[..]))));
|
||||
assert_eq!(item, ws::Frame::Binary(Bytes::from_static(b"text")));
|
||||
|
||||
framed.send(ws::Message::Ping("text".into())).await.unwrap();
|
||||
let item = framed.next().await.unwrap().unwrap();
|
||||
|
Reference in New Issue
Block a user