Skip to content

Commit 1a05dd4

Browse files
authored
Merge branch 'master' into request-read_timeout
2 parents 670e786 + f186803 commit 1a05dd4

File tree

2 files changed

+129
-1
lines changed

2 files changed

+129
-1
lines changed

src/blocking/client.rs

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,105 @@ impl ClientBuilder {
527527
self.with_inner(|inner| inner.http3_prior_knowledge())
528528
}
529529

530+
/// Maximum duration of inactivity to accept before timing out the QUIC connection.
531+
///
532+
/// Please see docs in [`TransportConfig`] in [`quinn`].
533+
///
534+
/// [`TransportConfig`]: https://docs.rs/quinn/latest/quinn/struct.TransportConfig.html
535+
#[cfg(feature = "http3")]
536+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
537+
pub fn http3_max_idle_timeout(self, value: Duration) -> ClientBuilder {
538+
self.with_inner(|inner| inner.http3_max_idle_timeout(value))
539+
}
540+
541+
/// Maximum number of bytes the peer may transmit without acknowledgement on any one stream
542+
/// before becoming blocked.
543+
///
544+
/// Please see docs in [`TransportConfig`] in [`quinn`].
545+
///
546+
/// [`TransportConfig`]: https://docs.rs/quinn/latest/quinn/struct.TransportConfig.html
547+
///
548+
/// # Panics
549+
///
550+
/// Panics if the value is over 2^62.
551+
#[cfg(feature = "http3")]
552+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
553+
pub fn http3_stream_receive_window(self, value: u64) -> ClientBuilder {
554+
self.with_inner(|inner| inner.http3_stream_receive_window(value))
555+
}
556+
557+
/// Maximum number of bytes the peer may transmit across all streams of a connection before
558+
/// becoming blocked.
559+
///
560+
/// Please see docs in [`TransportConfig`] in [`quinn`].
561+
///
562+
/// [`TransportConfig`]: https://docs.rs/quinn/latest/quinn/struct.TransportConfig.html
563+
///
564+
/// # Panics
565+
///
566+
/// Panics if the value is over 2^62.
567+
#[cfg(feature = "http3")]
568+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
569+
pub fn http3_conn_receive_window(self, value: u64) -> ClientBuilder {
570+
self.with_inner(|inner| inner.http3_conn_receive_window(value))
571+
}
572+
573+
/// Maximum number of bytes to transmit to a peer without acknowledgment
574+
///
575+
/// Please see docs in [`TransportConfig`] in [`quinn`].
576+
///
577+
/// [`TransportConfig`]: https://docs.rs/quinn/latest/quinn/struct.TransportConfig.html
578+
#[cfg(feature = "http3")]
579+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
580+
pub fn http3_send_window(self, value: u64) -> ClientBuilder {
581+
self.with_inner(|inner| inner.http3_send_window(value))
582+
}
583+
584+
/// Override the default congestion control algorithm to use [BBR]
585+
///
586+
/// The current default congestion control algorithm is [CUBIC]. This method overrides the
587+
/// default.
588+
///
589+
/// [BBR]: https://datatracker.ietf.org/doc/html/draft-ietf-ccwg-bbr
590+
/// [CUBIC]: https://datatracker.ietf.org/doc/html/rfc8312
591+
#[cfg(feature = "http3")]
592+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
593+
pub fn http3_congestion_bbr(self) -> ClientBuilder {
594+
self.with_inner(|inner| inner.http3_congestion_bbr())
595+
}
596+
597+
/// Set the maximum HTTP/3 header size this client is willing to accept.
598+
///
599+
/// See [header size constraints] section of the specification for details.
600+
///
601+
/// [header size constraints]: https://www.rfc-editor.org/rfc/rfc9114.html#name-header-size-constraints
602+
///
603+
/// Please see docs in [`Builder`] in [`h3`].
604+
///
605+
/// [`Builder`]: https://docs.rs/h3/latest/h3/client/struct.Builder.html#method.max_field_section_size
606+
#[cfg(feature = "http3")]
607+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
608+
pub fn http3_max_field_section_size(self, value: u64) -> ClientBuilder {
609+
self.with_inner(|inner| inner.http3_max_field_section_size(value))
610+
}
611+
612+
/// Enable whether to send HTTP/3 protocol grease on the connections.
613+
///
614+
/// HTTP/3 uses the concept of "grease"
615+
///
616+
/// to prevent potential interoperability issues in the future.
617+
/// In HTTP/3, the concept of grease is used to ensure that the protocol can evolve
618+
/// and accommodate future changes without breaking existing implementations.
619+
///
620+
/// Please see docs in [`Builder`] in [`h3`].
621+
///
622+
/// [`Builder`]: https://docs.rs/h3/latest/h3/client/struct.Builder.html#method.send_grease
623+
#[cfg(feature = "http3")]
624+
#[cfg_attr(docsrs, doc(cfg(all(reqwest_unstable, feature = "http3",))))]
625+
pub fn http3_send_grease(self, enabled: bool) -> ClientBuilder {
626+
self.with_inner(|inner| inner.http3_send_grease(enabled))
627+
}
628+
530629
// TCP options
531630

532631
/// Set whether sockets have `TCP_NODELAY` enabled.

src/proxy.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,15 @@ pub trait IntoProxy {
123123
impl<S: IntoUrl> IntoProxy for S {
124124
fn into_proxy(self) -> crate::Result<Url> {
125125
match self.as_str().into_url() {
126-
Ok(ok) => Ok(ok),
126+
Ok(mut url) => {
127+
// If the scheme is a SOCKS protocol and no port is specified, set the default
128+
if url.port().is_none()
129+
&& matches!(url.scheme(), "socks4" | "socks4a" | "socks5" | "socks5h")
130+
{
131+
let _ = url.set_port(Some(1080));
132+
}
133+
Ok(url)
134+
}
127135
Err(e) => {
128136
let mut presumed_to_have_scheme = true;
129137
let mut source = e.source();
@@ -910,4 +918,25 @@ mod tests {
910918
.into_matcher();
911919
assert!(m.maybe_has_http_auth(), "http forwards");
912920
}
921+
922+
#[test]
923+
fn test_socks_proxy_default_port() {
924+
{
925+
let m = Proxy::all("socks5://example.com").unwrap().into_matcher();
926+
927+
let http = "http://hyper.rs";
928+
let https = "https://hyper.rs";
929+
930+
assert_eq!(intercepted_uri(&m, http).port_u16(), Some(1080));
931+
assert_eq!(intercepted_uri(&m, https).port_u16(), Some(1080));
932+
933+
// custom port
934+
let m = Proxy::all("socks5://example.com:1234")
935+
.unwrap()
936+
.into_matcher();
937+
938+
assert_eq!(intercepted_uri(&m, http).port_u16(), Some(1234));
939+
assert_eq!(intercepted_uri(&m, https).port_u16(), Some(1234));
940+
}
941+
}
913942
}

0 commit comments

Comments
 (0)