Skip to content

Commit 86cfeee

Browse files
committed
Fix both feature structure and sending of close-notify messages.
1 parent a1c4952 commit 86cfeee

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "zeptohttpc"
33
description = "minimal HTTP client using http and httparse crates"
4-
version = "0.9.1"
4+
version = "0.9.2"
55
authors = ["Adam Reichold <[email protected]>"]
66
edition = "2018"
77
rust-version = "1.60"
@@ -17,8 +17,8 @@ encoding_rs = ["dep:encoding_rs"]
1717
flate2 = ["dep:flate2"]
1818
json = ["dep:serde", "dep:serde_json"]
1919
tls = ["tls-webpki-roots"]
20-
tls-webpki-roots = ["dep:rustls", "dep:webpki-roots", "dep:once_cell"]
21-
tls-native-roots = ["dep:rustls", "dep:rustls-native-certs", "dep:once_cell"]
20+
tls-webpki-roots = ["rustls", "dep:webpki-roots", "dep:once_cell"]
21+
tls-native-roots = ["rustls", "dep:rustls-native-certs", "dep:once_cell"]
2222
rustls = ["dep:rustls"]
2323
native-tls = ["dep:native-tls"]
2424

src/stream.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#[cfg(feature = "rustls")]
1515
use std::convert::TryFrom;
1616
#[cfg(feature = "rustls")]
17-
use std::io::ErrorKind::{ConnectionAborted, WouldBlock};
17+
use std::io::ErrorKind::{UnexpectedEof, WouldBlock};
1818
use std::io::{Read, Result as IoResult, Write};
1919
#[cfg(any(feature = "native-tls", feature = "rustls"))]
2020
use std::net::TcpStream;
@@ -25,15 +25,15 @@ use std::sync::Arc;
2525
use http::uri::Scheme;
2626
#[cfg(feature = "native-tls")]
2727
use native_tls::{HandshakeError, TlsConnector, TlsStream};
28-
#[cfg(any(feature = "webpki-roots", feature = "rustls-native-certs"))]
28+
#[cfg(any(feature = "tls-webpki-roots", feature = "tls-native-roots"))]
2929
use once_cell::sync::Lazy;
30-
#[cfg(any(feature = "webpki-roots", feature = "rustls-native-certs"))]
30+
#[cfg(any(feature = "tls-webpki-roots", feature = "tls-native-roots"))]
3131
use rustls::RootCertStore;
3232
#[cfg(feature = "rustls")]
3333
use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, StreamOwned};
34-
#[cfg(feature = "rustls-native-certs")]
34+
#[cfg(feature = "tls-native-roots")]
3535
use rustls_native_certs::load_native_certs;
36-
#[cfg(feature = "webpki-roots")]
36+
#[cfg(feature = "tls-webpki-roots")]
3737
use webpki_roots::TLS_SERVER_ROOTS;
3838

3939
use super::{happy_eyeballs::connect, timeout::Timeout, Error, Options};
@@ -166,15 +166,15 @@ fn perform_rustls_handshake(
166166

167167
let client_config = match client_config {
168168
Some(client_config) => client_config.clone(),
169-
#[cfg(any(feature = "webpki-roots", feature = "rustls-native-certs"))]
169+
#[cfg(any(feature = "tls-webpki-roots", feature = "tls-native-roots"))]
170170
None => {
171171
static CLIENT_CONFIG: Lazy<Arc<ClientConfig>> = Lazy::new(|| {
172172
let mut root_store = RootCertStore::empty();
173173

174-
#[cfg(feature = "webpki-roots")]
174+
#[cfg(feature = "tls-webpki-roots")]
175175
root_store.extend(TLS_SERVER_ROOTS.iter().cloned());
176176

177-
#[cfg(feature = "rustls-native-certs")]
177+
#[cfg(feature = "tls-native-roots")]
178178
for cert in load_native_certs().expect("Failed to load native roots") {
179179
root_store.add(cert).expect("Failed to add native root");
180180
}
@@ -188,7 +188,7 @@ fn perform_rustls_handshake(
188188

189189
CLIENT_CONFIG.clone()
190190
}
191-
#[cfg(not(any(feature = "webpki-roots", feature = "rustls-native-certs")))]
191+
#[cfg(not(any(feature = "tls-webpki-roots", feature = "tls-native-roots")))]
192192
None => return Err(Error::MissingTlsRoots),
193193
};
194194

@@ -212,7 +212,7 @@ impl Read for HandleCloseNotify {
212212
let res = self.0.read(buf);
213213

214214
match res {
215-
Err(err) if err.kind() == ConnectionAborted => {
215+
Err(err) if err.kind() == UnexpectedEof => {
216216
self.0.conn.send_close_notify();
217217
self.0.conn.complete_io(&mut self.0.sock)?;
218218

0 commit comments

Comments
 (0)