Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): add initial window builder methods that take self by-val #1817

Merged
merged 2 commits into from
May 16, 2019
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
11 changes: 4 additions & 7 deletions benches/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,11 @@ fn spawn_hello(rt: &mut Runtime, opts: &Opts) -> SocketAddr {
let addr = "127.0.0.1:0".parse().unwrap();

let body = opts.response_body;
let mut builder = Server::bind(&addr)
let srv = Server::bind(&addr)
.http2_only(opts.http2);
// api woopsie
builder
.http2_initial_stream_window_size(opts.http2_stream_window)
.http2_initial_connection_window_size(opts.http2_conn_window);

let srv = builder.serve(move || {
.http2_initial_stream_window_size_(opts.http2_stream_window)
.http2_initial_connection_window_size_(opts.http2_conn_window)
.serve(move || {
service_fn(move |req: Request<Body>| {
req
.into_body()
Expand Down
20 changes: 18 additions & 2 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,21 +302,37 @@ impl<I, E> Builder<I, E> {
self
}

// soft-deprecated? deprecation warning just seems annoying...
// reimplemented to take `self` instead of `&mut self`
#[doc(hidden)]
pub fn http2_initial_stream_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
self.protocol.http2_initial_stream_window_size(sz.into());
self
}

// soft-deprecated? deprecation warning just seems annoying...
// reimplemented to take `self` instead of `&mut self`
#[doc(hidden)]
pub fn http2_initial_connection_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
self.protocol.http2_initial_connection_window_size(sz.into());
self
}

/// Sets the [`SETTINGS_INITIAL_WINDOW_SIZE`][spec] option for HTTP2
/// stream-level flow control.
///
/// Default is 65,535
///
/// [spec]: https://http2.github.io/http2-spec/#SETTINGS_INITIAL_WINDOW_SIZE
pub fn http2_initial_stream_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
pub fn http2_initial_stream_window_size_(mut self, sz: impl Into<Option<u32>>) -> Self {
self.protocol.http2_initial_stream_window_size(sz.into());
self
}

/// Sets the max connection-level flow control for HTTP2
///
/// Default is 65,535
pub fn http2_initial_connection_window_size(&mut self, sz: impl Into<Option<u32>>) -> &mut Self {
pub fn http2_initial_connection_window_size_(mut self, sz: impl Into<Option<u32>>) -> Self {
self.protocol.http2_initial_connection_window_size(sz.into());
self
}
Expand Down