Skip to content

Commit

Permalink
doc client features. (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakeshadow authored Mar 27, 2024
1 parent 8be1d73 commit fece8b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
30 changes: 20 additions & 10 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@ version = "0.1.0"
edition = "2021"

[features]
# default feature includes http/1 clear text client.
default = ["http1"]
# http/1 clear text client
http1 = ["httparse", "xitca-http/http1"]
# http/2 client(tls enabled by default. see `dangerous` feature for clear text http/2)
http2 = ["h2", "itoa", "xitca-http/http2"]
# htt/3 client(tls always enabled with rustls)
http3 = ["h3", "h3-quinn", "quinn/tls-rustls", "itoa", "async-stream", "rustls_0dot21", "webpki_roots_0dot25"]
# openssl as http/1 and http/2 tls handler.
openssl = ["xitca-tls/openssl"]
# rustls as http/1 and http/2 tls handler
rustls = ["xitca-tls/rustls", "webpki-roots"]
# rustls as tls handler with ring as crypto provider
rustls-ring-crypto = ["xitca-tls/rustls-ring-crypto", "webpki-roots"]
# compression and decompression middleware support
compress = ["http-encoding"]
# json response body parsing support
json = ["serde", "serde_json"]
# websocket support
websocket = ["http-ws"]

# used to test niche client side usage and correctness of server implemenation:
# feature for testing niche client side usage and correctness of server implemenation:
# - http/2 clear text over plain tcp connection
# - http/3 connection to server with self signed certificates.
dangerous = ["rustls_0dot21/dangerous_configuration"]
Expand All @@ -31,13 +41,13 @@ pin-project-lite = "0.2.9"
tokio = { version = "1.30", features = ["sync", "time"] }
tracing = { version = "0.1.40", default-features = false }

# http/1 support
# http/1
httparse = { version = "1.8.0", optional = true }

# http/2 support
# http/2
h2 = { version = "0.4", optional = true }

# http/3 support
# http/3
h3 = { version = "0.0.4", optional = true }
h3-quinn = { version = "0.0.5", optional = true }
quinn = { version = "0.10", optional = true }
Expand All @@ -46,26 +56,26 @@ async-stream = { version = "0.3", optional = true }
# http/2 and http/3 shared
itoa = { version = "1", optional = true }

# tls support shared
# tls shared
xitca-tls = { version = "0.2.2", optional = true }

# rustls, http3 and dangerous features shared support
# rustls, http3 and dangerous features shared
webpki-roots = { version = "0.26", optional = true }

# http3 temporary exclusive
rustls_0dot21 = { package = "rustls", version = "0.21", optional = true }
webpki_roots_0dot25 = { package = "webpki-roots", version = "0.25", optional = true }

# compression support
# compression
http-encoding = { version = "0.2", features = ["br", "gz", "de"], optional = true }

# serde support
# serde
serde = { version = "1.0.130", default-features = false, optional = true }

# json support
# json
serde_json = { version = "1", optional = true }

# websocket support
# websocket
http-ws = { version = "0.3", features = ["stream"], optional = true }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion client/src/http_tunnel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ where
}
}

while let Err(e) = (&mut **body.conn()).flush() {
while let Err(e) = (**body.conn()).flush() {
if e.kind() != io::ErrorKind::WouldBlock {
return Poll::Ready(Err(e.into()));
}
Expand Down
12 changes: 6 additions & 6 deletions client/src/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,26 @@ impl Sink<Message> for WebSocketTunnel<'_> {
use std::io::{self, Write};
use xitca_io::io::{AsyncIo, Interest};

while !inner.send_buf.chunk().is_empty() {
let io = &mut **body.conn();
let mut io = Pin::new(&mut **body.conn());

match io.write(inner.send_buf.chunk()) {
while !inner.send_buf.chunk().is_empty() {
match io.as_mut().get_mut().write(inner.send_buf.chunk()) {
Ok(0) => return Poll::Ready(Err(io::Error::from(io::ErrorKind::UnexpectedEof).into())),
Ok(n) => {
inner.send_buf.advance(n);
}
Err(e) if e.kind() == io::ErrorKind::WouldBlock => {
ready!(Pin::new(io).poll_ready(Interest::WRITABLE, _cx))?;
ready!(io.as_mut().poll_ready(Interest::WRITABLE, _cx))?;
}
Err(e) => return Poll::Ready(Err(e.into())),
}
}

while let Err(e) = (&mut **body.conn()).flush() {
while let Err(e) = io.as_mut().get_mut().flush() {
if e.kind() != io::ErrorKind::WouldBlock {
return Poll::Ready(Err(e.into()));
}
ready!(Pin::new(&mut **body.conn()).poll_ready(Interest::WRITABLE, _cx))?;
ready!(io.as_mut().poll_ready(Interest::WRITABLE, _cx))?;
}

Poll::Ready(Ok(()))
Expand Down

0 comments on commit fece8b8

Please sign in to comment.