Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/emulation_firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async fn main() -> wreq::Result<()> {
Http2Options::builder()
.initial_stream_id(15)
.header_table_size(65536)
.initial_stream_window_size(131072)
.initial_window_size(131072)
.max_frame_size(16384)
.initial_connection_window_size(12517377 + 65535)
.headers_stream_dependency(StreamDependency::new(StreamId::from(13), 41, false))
Expand Down
2 changes: 1 addition & 1 deletion examples/emulation_twitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn main() -> wreq::Result<()> {
// HTTP/2 options config
let http2 = Http2Options::builder()
.initial_stream_id(3)
.initial_stream_window_size(16777216)
.initial_window_size(16777216)
.initial_connection_window_size(16711681 + 65535)
.headers_pseudo_order(
PseudoOrder::builder()
Expand Down
2 changes: 1 addition & 1 deletion examples/keylog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ async fn main() -> wreq::Result<()> {
// Use the API you're already familiar with
let resp = client.get("https://api.ip.sb/ip").send().await?;
println!("{}", resp.text().await?);

Ok(())
}
2 changes: 1 addition & 1 deletion examples/request_with_emulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn main() -> wreq::Result<()> {
// HTTP/2 options config
let http2 = Http2Options::builder()
.initial_stream_id(3)
.initial_stream_window_size(16777216)
.initial_window_size(16777216)
.initial_connection_window_size(16711681 + 65535)
.headers_pseudo_order(
PseudoOrder::builder()
Expand Down
13 changes: 7 additions & 6 deletions src/core/client/conn/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where
/// are subject to change at any time.
#[derive(Clone, Debug)]
pub struct Builder {
config: Http1Options,
opts: Http1Options,
}

// ===== impl SendRequest
Expand Down Expand Up @@ -228,13 +228,14 @@ impl Builder {
#[inline]
pub fn new() -> Builder {
Builder {
config: Default::default(),
opts: Default::default(),
}
}

pub fn config(&mut self, opts: Option<Http1Options>) {
if let Some(config) = opts {
self.config = config;
/// Provide a options configuration for the HTTP/1 connection.
pub fn options(&mut self, opts: Option<Http1Options>) {
if let Some(opts) = opts {
self.opts = opts;
}
}

Expand All @@ -253,7 +254,7 @@ impl Builder {
B::Data: Send,
B::Error: Into<BoxError>,
{
let opts = self.config.clone();
let opts = self.opts.clone();

async move {
trace!("client handshake HTTP/1");
Expand Down
25 changes: 13 additions & 12 deletions src/core/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ where
/// are subject to change at any time.
#[derive(Clone, Debug)]
pub struct Builder<Ex> {
pub(super) exec: Ex,
pub(super) timer: Time,
config: Http2Options,
exec: Ex,
timer: Time,
opts: Http2Options,
}

// ===== impl SendRequest
Expand Down Expand Up @@ -194,7 +194,7 @@ where
Builder {
exec,
timer: Time::Empty,
config: Default::default(),
opts: Default::default(),
}
}

Expand All @@ -206,10 +206,10 @@ where
self.timer = Time::Timer(Arc::new(timer));
}

/// Provide a configuration for HTTP/2.
pub fn config(&mut self, opts: Option<Http2Options>) {
if let Some(config) = opts {
self.config = config;
/// Provide a options configuration for the HTTP/2 connection.
pub fn options(&mut self, opts: Option<Http2Options>) {
if let Some(opts) = opts {
self.opts = opts;
}
}

Expand All @@ -229,7 +229,7 @@ where
B::Error: Into<BoxError>,
Ex: Http2ClientConnExec<B, T> + Unpin,
{
let opts = self.clone();
let builder = self.clone();

async move {
trace!("client handshake HTTP/2");
Expand All @@ -238,9 +238,10 @@ where
let h2 = proto::h2::client::handshake(
io,
rx,
&opts.config.h2_builder,
opts.exec,
opts.timer,
builder.opts.builder,
builder.opts.ping_config,
builder.exec,
builder.timer,
)
.await?;
Ok((
Expand Down
8 changes: 4 additions & 4 deletions src/core/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ where
if let Some(opts) = transport_options {
let (tls, http1, http2) = opts.into_parts();
tls_options = tls;
this.h1_builder.config(http1);
this.h2_builder.config(http2);
this.h1_builder.options(http1);
this.h2_builder.options(http2);
}

let conn_req = ConnRequest {
Expand Down Expand Up @@ -1131,13 +1131,13 @@ impl Builder {

/// Provide a configuration for HTTP/1.
pub fn http1_options(&mut self, opts: Option<Http1Options>) -> &mut Self {
self.h1_builder.config(opts);
self.h1_builder.options(opts);
self
}

/// Provide a configuration for HTTP/2.
pub fn http2_options(&mut self, opts: Option<Http2Options>) -> &mut Self {
self.h2_builder.config(opts);
self.h2_builder.options(opts);
self
}

Expand Down
28 changes: 14 additions & 14 deletions src/core/client/options/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::core::proto;
#[must_use]
#[derive(Debug)]
pub struct Http1OptionsBuilder {
config: Http1Options,
opts: Http1Options,
}

/// HTTP/1 protocol options for customizing connection behavior.
Expand All @@ -29,7 +29,7 @@ pub struct Http1Options {
impl Http1OptionsBuilder {
/// Set the `http09_responses` field.
pub fn http09_responses(mut self, enabled: bool) -> Self {
self.config.h09_responses = enabled;
self.opts.h09_responses = enabled;
self
}

Expand All @@ -46,7 +46,7 @@ impl Http1OptionsBuilder {
/// Default is `auto`. In this mode crate::core: will try to guess which
/// mode to use
pub fn writev(mut self, writev: Option<bool>) -> Self {
self.config.h1_writev = writev;
self.opts.h1_writev = writev;
self
}

Expand All @@ -58,7 +58,7 @@ impl Http1OptionsBuilder {
///
/// Default is false.
pub fn preserve_header_case(mut self, preserve_header_case: bool) -> Self {
self.config.h1_preserve_header_case = preserve_header_case;
self.opts.h1_preserve_header_case = preserve_header_case;
self
}

Expand All @@ -76,7 +76,7 @@ impl Http1OptionsBuilder {
///
/// Default is 100.
pub fn max_headers(mut self, max_headers: usize) -> Self {
self.config.h1_max_headers = Some(max_headers);
self.opts.h1_max_headers = Some(max_headers);
self
}

Expand All @@ -86,8 +86,8 @@ impl Http1OptionsBuilder {
///
/// Default is an adaptive read buffer.
pub fn read_buf_exact_size(mut self, sz: Option<usize>) -> Self {
self.config.h1_read_buf_exact_size = sz;
self.config.h1_max_buf_size = None;
self.opts.h1_read_buf_exact_size = sz;
self.opts.h1_max_buf_size = None;
self
}

Expand All @@ -107,8 +107,8 @@ impl Http1OptionsBuilder {
"the max_buf_size cannot be smaller than the minimum that h1 specifies."
);

self.config.h1_max_buf_size = Some(max);
self.config.h1_read_buf_exact_size = None;
self.opts.h1_max_buf_size = Some(max);
self.opts.h1_read_buf_exact_size = None;
self
}

Expand All @@ -130,7 +130,7 @@ impl Http1OptionsBuilder {
///
/// [RFC 7230 Section 3.2.4.]: https://tools.ietf.org/html/rfc7230#section-3.2.4
pub fn allow_spaces_after_header_name_in_responses(mut self, enabled: bool) -> Self {
self.config
self.opts
.h1_parser_config
.allow_spaces_after_header_name_in_responses(enabled);
self
Expand All @@ -144,7 +144,7 @@ impl Http1OptionsBuilder {
///
/// Default is false.
pub fn ignore_invalid_headers_in_responses(mut self, enabled: bool) -> Self {
self.config
self.opts
.h1_parser_config
.ignore_invalid_headers_in_responses(enabled);
self
Expand All @@ -155,7 +155,7 @@ impl Http1OptionsBuilder {
mut self,
allow_obsolete_multiline_headers_in_responses: bool,
) -> Self {
self.config
self.opts
.h1_parser_config
.allow_obsolete_multiline_headers_in_responses(
allow_obsolete_multiline_headers_in_responses,
Expand All @@ -165,15 +165,15 @@ impl Http1OptionsBuilder {

/// Build the `Http1Options` instance.
pub fn build(self) -> Http1Options {
self.config
self.opts
}
}

impl Http1Options {
/// Create a new `Http1OptionsBuilder`.
pub fn builder() -> Http1OptionsBuilder {
Http1OptionsBuilder {
config: Http1Options::default(),
opts: Http1Options::default(),
}
}
}
Loading
Loading