Skip to content

Commit 912a557

Browse files
committed
Merge #563: bitreq: Fix tokio-rustls feature gate
f4f1c19 Fix tokio-rustls feature gate (Jamil Lambert, PhD) Pull request description: The code was gated on the dependency instead of the feature alias which enables other required dependencies. This caused a build failure when both `std` and `tokio-rustls` features were enabled and not the other required dependencies. Change the feature gate to the feature alias instead of the dependency. ACKs for top commit: ton-anywhere: ACK f4f1c19 tnull: ACK f4f1c19 luisschwab: ACK f4f1c19 Tree-SHA512: c121efce008c57f446bdbfb5684f1520c935b4253586b969932d4992845549245b67aa9f2eba61549df449fccd6db86acfd4ce6b83affb8072017f29da84ccc9
2 parents cc61db9 + f4f1c19 commit 912a557

2 files changed

Lines changed: 15 additions & 12 deletions

File tree

bitreq/src/connection.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ impl Write for HttpStream {
158158
}
159159
}
160160

161-
#[cfg(feature = "tokio-rustls")]
161+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
162162
type AsyncSecuredStream = rustls_stream::AsyncSecuredStream;
163163

164164
#[cfg(feature = "async")]
165165
pub(crate) enum AsyncHttpStream {
166166
Unsecured(AsyncTcpStream),
167-
#[cfg(feature = "tokio-rustls")]
167+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
168168
Secured(Box<AsyncSecuredStream>),
169169
}
170170

@@ -177,7 +177,7 @@ impl AsyncRead for AsyncHttpStream {
177177
) -> Poll<io::Result<()>> {
178178
match &mut *self {
179179
AsyncHttpStream::Unsecured(inner) => Pin::new(inner).poll_read(cx, buf),
180-
#[cfg(feature = "tokio-rustls")]
180+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
181181
AsyncHttpStream::Secured(inner) => Pin::new(inner).poll_read(cx, buf),
182182
}
183183
}
@@ -192,23 +192,23 @@ impl AsyncWrite for AsyncHttpStream {
192192
) -> Poll<io::Result<usize>> {
193193
match &mut *self {
194194
AsyncHttpStream::Unsecured(inner) => Pin::new(inner).poll_write(cx, buf),
195-
#[cfg(feature = "tokio-rustls")]
195+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
196196
AsyncHttpStream::Secured(inner) => Pin::new(inner).poll_write(cx, buf),
197197
}
198198
}
199199

200200
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
201201
match &mut *self {
202202
AsyncHttpStream::Unsecured(inner) => Pin::new(inner).poll_flush(cx),
203-
#[cfg(feature = "tokio-rustls")]
203+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
204204
AsyncHttpStream::Secured(inner) => Pin::new(inner).poll_flush(cx),
205205
}
206206
}
207207

208208
fn poll_shutdown(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> {
209209
match &mut *self {
210210
AsyncHttpStream::Unsecured(inner) => Pin::new(inner).poll_shutdown(cx),
211-
#[cfg(feature = "tokio-rustls")]
211+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
212212
AsyncHttpStream::Secured(inner) => Pin::new(inner).poll_shutdown(cx),
213213
}
214214
}
@@ -271,9 +271,12 @@ impl AsyncConnection {
271271
let socket = Self::connect(params).await?;
272272

273273
if params.https {
274-
#[cfg(not(feature = "tokio-rustls"))]
274+
#[cfg(not(any(
275+
feature = "async-https-rustls",
276+
feature = "async-https-rustls-probe"
277+
)))]
275278
return Err(Error::HttpsFeatureNotEnabled);
276-
#[cfg(feature = "tokio-rustls")]
279+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
277280
rustls_stream::wrap_async_stream(socket, params.host).await
278281
} else {
279282
Ok(AsyncHttpStream::Unsecured(socket))

bitreq/src/connection/rustls_stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ use rustls::pki_types::ServerName;
1515
use rustls::{self, ClientConfig, ClientConnection, RootCertStore, StreamOwned};
1616
#[cfg(all(feature = "native-tls", not(feature = "rustls"), feature = "tokio-native-tls"))]
1717
use tokio_native_tls::TlsConnector as AsyncTlsConnector;
18-
#[cfg(feature = "tokio-rustls")]
18+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
1919
use tokio_rustls::{client::TlsStream, TlsConnector};
2020
#[cfg(feature = "rustls-webpki")]
2121
use webpki_roots::TLS_SERVER_ROOTS;
2222

23-
#[cfg(feature = "tokio-rustls")]
23+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
2424
use super::{AsyncHttpStream, AsyncTcpStream};
2525
#[cfg(all(feature = "native-tls", not(feature = "rustls"), feature = "tokio-native-tls"))]
2626
use super::{AsyncHttpStream, AsyncTcpStream};
@@ -66,10 +66,10 @@ pub(super) fn wrap_stream(tcp: TcpStream, host: &str) -> Result<SecuredStream, E
6666

6767
// Async rustls TLS implementation
6868

69-
#[cfg(all(feature = "rustls", feature = "tokio-rustls"))]
69+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
7070
pub type AsyncSecuredStream = TlsStream<tokio::net::TcpStream>;
7171

72-
#[cfg(all(feature = "rustls", feature = "tokio-rustls"))]
72+
#[cfg(any(feature = "async-https-rustls", feature = "async-https-rustls-probe"))]
7373
pub(super) async fn wrap_async_stream(
7474
tcp: AsyncTcpStream,
7575
host: &str,

0 commit comments

Comments
 (0)