-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.
Description
Hi, I'd like to request that hyper::proto::h2::H2Upgraded<T> be made pub, so users can downcast an hyper::upgrade::Upgraded object to access the underlying I/O type for HTTP/2 connections.
Problem
Currently, Upgraded is not Sync, which prevents sending it across threads or storing it in Sync contexts. While HTTP/1 upgraded connections can be downcast using .downcast::<Tokio<TcpStream >>(), but the underlying I/O type for HTTP/2 H2Upgraded<T> is private, making it impossible to downcast and recover the inner IO (which is often Sync).
// This fails to compile — `H2Upgraded` is private
upgraded.downcast::<hyper::proto::h2::H2Upgraded<bytes::Bytes>>()Note
- The construction of H2Upgraded:
- client side:
Lines 591 to 593 in be18a92
let (h2_up, up_task) = super::upgrade::pair(send_stream, recv_stream, ping); self.exec.execute_upgrade(up_task); let upgraded = Upgraded::new(h2_up, Bytes::new()); - server side:
Lines 495 to 503 in be18a92
let (h2_up, up_task) = super::upgrade::pair( send_stream, connect_parts.recv_stream, connect_parts.ping, ); connect_parts .pending .fulfill(Upgraded::new(h2_up, Bytes::new())); self.exec.execute_upgrade(up_task);
- client side:
- This issue is partly similar to hyper-util auto version detection breaks the ability to use
Upgraded::downcast#3587, but it doesn't solve the problem in the HTTP/2 scenario.
Thanks for all the great work on Hyper! I'd be happy to help implement this if you agree.
Metadata
Metadata
Assignees
Labels
C-featureCategory: feature. This is adding a new feature.Category: feature. This is adding a new feature.