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

Provide From<Message> for Request #1036

Closed
alexcrichton opened this issue Jan 26, 2017 · 2 comments
Closed

Provide From<Message> for Request #1036

alexcrichton opened this issue Jan 26, 2017 · 2 comments

Comments

@alexcrichton
Copy link
Contributor

I've taken most of the ideas learned here about spawning servers back to tokio-proto in tokio-rs/tokio-proto#135 and I believe the only remaining blocker for hyper being compatible with tokio-proto's TcpServer is the usage of SocketAddr in Hyper's request type. If this can be handled to implement From<Message> for Request then Hyper could leverage support in tokio-rs/tokio-proto#130 to use TcpServer directly, especially when working with TLS connections where Hyper's conveniences won't be available.

Talking with @carllerche over lunch today one idea was to have the socket address be a member of the messages coming from the Stream going into tokio-proto. That way the message itself would contain the socket address. I could imagine this being implemented via a trait bound in Hyper perhaps?

What do you think?

@seanmonstar
Copy link
Member

That definitely sounds good. This is basically for this line: https://github.com/hyperium/hyper/blob/master/src/server/mod.rs#L258

So, impl From<Message<ProtoRequest, http::TokioBody> for Request? I could move the SocketAddr into the ProtoRequest type, but I don't know how someone would make use of this, since they cannot create those types...

@alexcrichton
Copy link
Contributor Author

Yeah that's the impl I was thinking of. I don't think users would use this explicitly, but that way Hyper "as is" would hook into tokio-proto's TcpServer so that could be used off the bat.

seanmonstar added a commit that referenced this issue Feb 4, 2017
This implements `From<Message> for Request` and `Into<Message> for
Response`, allowing an `Http` instance to be used with a `TcpServer`
from tokio-proto.

Closes #1036

BREAKING CHANGE: This makes `Request.remote_addr` an
  `Option<SocketAddr>`, instead of `SocketAddr`.
seanmonstar added a commit that referenced this issue Feb 17, 2017
This implements `From<Message> for Request` and `Into<Message> for
Response`, allowing an `Http` instance to be used with a `TcpServer`
from tokio-proto.

Closes #1036

BREAKING CHANGE: This makes `Request.remote_addr` an
  `Option<SocketAddr>`, instead of `SocketAddr`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants