Skip to content

Commit dfacd76

Browse files
committed
Remove unecessary changes to client.rs
1 parent 756481e commit dfacd76

File tree

4 files changed

+9
-44
lines changed

4 files changed

+9
-44
lines changed

contract-tests/src/bin/sse-test-api/main.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ struct Config {
2626
/// test harness will send a value anyway in an attempt to avoid having reconnection tests
2727
/// run unnecessarily slowly.
2828
initial_delay_ms: Option<u64>,
29-
/// An optional integer specifying the read timeout for the connection, in
30-
/// milliseconds.
31-
read_timeout_ms: Option<u64>,
3229
/// A JSON object containing additional HTTP header names and string values. The SSE
3330
/// client should be configured to add these headers to its HTTP requests; the test harness
3431
/// will then verify that it receives those headers. The test harness will only set this
@@ -72,7 +69,6 @@ async fn status() -> impl Responder {
7269
"comments".to_string(),
7370
"post".to_string(),
7471
"report".to_string(),
75-
"read-timeout".to_string(),
7672
"headers".to_string(),
7773
"last-event-id".to_string(),
7874
],

contract-tests/src/bin/sse-test-api/stream_entity.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use eventsource_client as es;
1010

1111
use crate::{Config, EventType};
1212

13-
type Connector = es::TimeoutConnector<es::HttpsConnector>;
13+
type Connector = es::HttpsConnector;
1414

1515
pub(crate) struct Inner {
1616
callback_counter: Mutex<i32>,
@@ -101,10 +101,6 @@ impl Inner {
101101
reconnect_options = reconnect_options.delay(Duration::from_millis(delay_ms));
102102
}
103103

104-
if let Some(read_timeout_ms) = config.read_timeout_ms {
105-
client_builder = client_builder.read_timeout(Duration::from_millis(read_timeout_ms));
106-
}
107-
108104
if let Some(headers) = &config.headers {
109105
for (name, value) in headers {
110106
client_builder = match client_builder.header(name, value) {

eventsource-client/examples/tail.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ async fn main() -> Result<(), es::Error> {
3636
Ok(())
3737
}
3838

39-
fn tail_events(
40-
client: es::Client<es::TimeoutConnector<es::HttpsConnector>>,
41-
) -> impl Stream<Item = Result<(), ()>> {
39+
fn tail_events(client: es::Client<es::HttpsConnector>) -> impl Stream<Item = Result<(), ()>> {
4240
client
4341
.stream()
4442
.map_ok(|event| {

eventsource-client/src/client.rs

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,23 @@ use std::{
1111
use futures::{ready, Stream};
1212
use hyper::{
1313
body::{Bytes, HttpBody},
14-
client::{
15-
connect::{Connect, Connection},
16-
ResponseFuture,
17-
},
14+
client::{connect::Connect, ResponseFuture},
1815
header::{HeaderMap, HeaderName, HeaderValue},
19-
service::Service,
2016
Body, Request, StatusCode, Uri,
2117
};
2218
#[cfg(feature = "rustls")]
2319
use hyper_rustls::HttpsConnector as RustlsConnector;
2420
use log::{debug, info, trace, warn};
2521
use pin_project::pin_project;
26-
27-
use tokio::{
28-
io::{AsyncRead, AsyncWrite},
29-
time::Sleep,
30-
};
22+
use tokio::time::Sleep;
3123

3224
use super::config::ReconnectOptions;
3325
use super::decode::Decoded;
3426
use super::error::{Error, Result};
3527

3628
pub use hyper::client::HttpConnector;
37-
3829
#[cfg(feature = "rustls")]
3930
pub type HttpsConnector = RustlsConnector<HttpConnector>;
40-
pub use hyper_timeout::TimeoutConnector;
4131

4232
/*
4333
* TODO remove debug output
@@ -48,7 +38,6 @@ pub struct ClientBuilder {
4838
url: Uri,
4939
headers: HeaderMap,
5040
reconnect_opts: ReconnectOptions,
51-
read_timeout: Option<Duration>,
5241
}
5342

5443
impl ClientBuilder {
@@ -64,12 +53,6 @@ impl ClientBuilder {
6453
Ok(self)
6554
}
6655

67-
/// Set a read timeout for the underlying connection. There is no read timeout by default.
68-
pub fn read_timeout(mut self, read_timeout: Duration) -> ClientBuilder {
69-
self.read_timeout = Some(read_timeout);
70-
self
71-
}
72-
7356
/// Configure the client's reconnect behaviour according to the supplied
7457
/// [`ReconnectOptions`].
7558
///
@@ -79,19 +62,12 @@ impl ClientBuilder {
7962
self
8063
}
8164

82-
pub fn build_with_conn<C>(self, conn: C) -> Client<TimeoutConnector<C>>
65+
pub fn build_with_conn<C>(self, conn: C) -> Client<C>
8366
where
84-
C: Service<Uri> + Send + 'static + std::clone::Clone,
85-
C::Error: Into<Box<dyn std::error::Error + Send + Sync>>,
86-
C::Future: Unpin + Send,
87-
C::Response: AsyncRead + AsyncWrite + Connection + Unpin + Send,
67+
C: Connect + Clone,
8868
{
89-
let mut connector = TimeoutConnector::new(conn);
90-
connector.set_read_timeout(self.read_timeout);
91-
let client = hyper::Client::builder().build::<_, hyper::Body>(connector);
92-
9369
Client {
94-
http: client,
70+
http: hyper::Client::builder().build(conn),
9571
request_props: RequestProps {
9672
url: self.url,
9773
headers: self.headers,
@@ -100,12 +76,12 @@ impl ClientBuilder {
10076
}
10177
}
10278

103-
pub fn build_http(self) -> Client<TimeoutConnector<HttpConnector>> {
79+
pub fn build_http(self) -> Client<HttpConnector> {
10480
self.build_with_conn(HttpConnector::new())
10581
}
10682

10783
#[cfg(feature = "rustls")]
108-
pub fn build(self) -> Client<TimeoutConnector<HttpsConnector>> {
84+
pub fn build(self) -> Client<HttpsConnector> {
10985
let conn = HttpsConnector::with_native_roots();
11086
self.build_with_conn(conn)
11187
}
@@ -150,7 +126,6 @@ impl Client<()> {
150126
url,
151127
headers: HeaderMap::new(),
152128
reconnect_opts: ReconnectOptions::default(),
153-
read_timeout: None,
154129
})
155130
}
156131
}

0 commit comments

Comments
 (0)