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

TCP_NODELAY on client #1473

Closed
1tgr opened this issue Mar 27, 2018 · 2 comments
Closed

TCP_NODELAY on client #1473

1tgr opened this issue Mar 27, 2018 · 2 comments
Labels
A-client Area: client. E-easy Effort: easy. A task that would be a great starting point for a new contributor.

Comments

@1tgr
Copy link

1tgr commented Mar 27, 2018

How can I set nodelay on an HTTP client connection? If it's not exposed by hyper, can I get access to the underlying TcpStream so I can call TcpStream::set_nodelay?

@seanmonstar
Copy link
Member

There's no super easy way currently. You could make a connector that wraps the HttpConnector, accessing the TcpStream there.

I'd be fine with this being an option on HttpConnector directly ...

@1tgr
Copy link
Author

1tgr commented Mar 28, 2018

Thanks, I came up with this wrapper for now:

pub struct HttpNoDelayConnector(HttpConnector);

impl Service for HttpNoDelayConnector {
    type Request = Uri;
    type Response = TcpStream;
    type Error = io::Error;
    type Future = Box<Future<Item=Self::Response, Error=Self::Error>>;

    fn call(&self, uri: Uri) -> Self::Future {
        Box::new(self.0.call(uri).and_then(|s| {
            s.set_nodelay(true)?;
            Ok(s)
        }))
    }
}

Will see if I can put together a pull request to set this directly on HttpConnector. With HTTP, I'm not sure there's a reason not to make TCP_NODELAY the default.

@seanmonstar seanmonstar added A-client Area: client. E-easy Effort: easy. A task that would be a great starting point for a new contributor. labels Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-client Area: client. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
None yet
Development

No branches or pull requests

2 participants