@@ -18,17 +18,16 @@ use http::{Method, StatusCode};
1818use pin_project_lite:: pin_project;
1919
2020use super :: ping:: { Ponger , Recorder } ;
21- use super :: { ping, H2Upgraded , PipeToSendStream , SendBuf } ;
21+ use super :: { ping, PipeToSendStream , SendBuf } ;
2222use crate :: body:: { Body , Incoming as IncomingBody } ;
2323use crate :: client:: dispatch:: { Callback , SendWhen , TrySendError } ;
2424use crate :: common:: either:: Either ;
2525use crate :: common:: io:: Compat ;
2626use crate :: common:: time:: Time ;
2727use crate :: ext:: Protocol ;
2828use crate :: headers;
29- use crate :: proto:: h2:: UpgradedSendStream ;
3029use crate :: proto:: Dispatched ;
31- use crate :: rt:: bounds:: Http2ClientConnExec ;
30+ use crate :: rt:: bounds:: { Http2ClientConnExec , Http2UpgradedExec } ;
3231use crate :: upgrade:: Upgraded ;
3332use crate :: { Request , Response } ;
3433use h2:: client:: ResponseFuture ;
@@ -151,7 +150,7 @@ where
151150 T : Read + Write + Unpin ,
152151 B : Body + ' static ,
153152 B :: Data : Send + ' static ,
154- E : Http2ClientConnExec < B , T > + Unpin ,
153+ E : Http2ClientConnExec < B , T > + Clone + Unpin ,
155154 B :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
156155{
157156 let ( h2_tx, mut conn) = new_builder ( config)
@@ -357,7 +356,7 @@ where
357356
358357pin_project ! {
359358 #[ project = H2ClientFutureProject ]
360- pub enum H2ClientFuture <B , T >
359+ pub enum H2ClientFuture <B , T , E >
361360 where
362361 B : http_body:: Body ,
363362 B : ' static ,
@@ -372,7 +371,7 @@ pin_project! {
372371 } ,
373372 Send {
374373 #[ pin]
375- send_when: SendWhen <B >,
374+ send_when: SendWhen <B , E >,
376375 } ,
377376 Task {
378377 #[ pin]
@@ -381,11 +380,12 @@ pin_project! {
381380 }
382381}
383382
384- impl < B , T > Future for H2ClientFuture < B , T >
383+ impl < B , T , E > Future for H2ClientFuture < B , T , E >
385384where
386385 B : http_body:: Body + ' static ,
387386 B :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
388387 T : Read + Write + Unpin ,
388+ E : Http2UpgradedExec < B :: Data > ,
389389{
390390 type Output = ( ) ;
391391
@@ -484,7 +484,7 @@ impl<B, E, T> ClientTask<B, E, T>
484484where
485485 B : Body + ' static + Unpin ,
486486 B :: Data : Send ,
487- E : Http2ClientConnExec < B , T > + Unpin ,
487+ E : Http2ClientConnExec < B , T > + Clone + Unpin ,
488488 B :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
489489 T : Read + Write + Unpin ,
490490{
@@ -529,6 +529,7 @@ where
529529 fut : f. fut ,
530530 ping : Some ( ping) ,
531531 send_stream : Some ( send_stream) ,
532+ exec : self . executor . clone ( ) ,
532533 } ,
533534 call_back : Some ( f. cb ) ,
534535 } ,
@@ -537,28 +538,29 @@ where
537538}
538539
539540pin_project ! {
540- pub ( crate ) struct ResponseFutMap <B >
541+ pub ( crate ) struct ResponseFutMap <B , E >
541542 where
542543 B : Body ,
543544 B : ' static ,
544545 {
545546 #[ pin]
546547 fut: ResponseFuture ,
547- #[ pin]
548548 ping: Option <Recorder >,
549549 #[ pin]
550550 send_stream: Option <Option <SendStream <SendBuf <<B as Body >:: Data >>>>,
551+ exec: E ,
551552 }
552553}
553554
554- impl < B > Future for ResponseFutMap < B >
555+ impl < B , E > Future for ResponseFutMap < B , E >
555556where
556557 B : Body + ' static ,
558+ E : Http2UpgradedExec < B :: Data > ,
557559{
558560 type Output = Result < Response < crate :: body:: Incoming > , ( crate :: Error , Option < Request < B > > ) > ;
559561
560- fn poll ( self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
561- let mut this = self . project ( ) ;
562+ fn poll ( mut self : Pin < & mut Self > , cx : & mut Context < ' _ > ) -> Poll < Self :: Output > {
563+ let mut this = self . as_mut ( ) . project ( ) ;
562564
563565 let result = ready ! ( this. fut. poll( cx) ) ;
564566
@@ -585,13 +587,10 @@ where
585587 let mut res = Response :: from_parts ( parts, IncomingBody :: empty ( ) ) ;
586588
587589 let ( pending, on_upgrade) = crate :: upgrade:: pending ( ) ;
588- let io = H2Upgraded {
589- ping,
590- send_stream : unsafe { UpgradedSendStream :: new ( send_stream) } ,
591- recv_stream,
592- buf : Bytes :: new ( ) ,
593- } ;
594- let upgraded = Upgraded :: new ( io, Bytes :: new ( ) ) ;
590+
591+ let ( h2_up, up_task) = super :: upgrade:: pair ( send_stream, recv_stream, ping) ;
592+ self . exec . execute_upgrade ( up_task) ;
593+ let upgraded = Upgraded :: new ( h2_up, Bytes :: new ( ) ) ;
595594
596595 pending. fulfill ( upgraded) ;
597596 res. extensions_mut ( ) . insert ( on_upgrade) ;
@@ -620,7 +619,7 @@ where
620619 B : Body + ' static + Unpin ,
621620 B :: Data : Send ,
622621 B :: Error : Into < Box < dyn std:: error:: Error + Send + Sync > > ,
623- E : Http2ClientConnExec < B , T > + Unpin ,
622+ E : Http2ClientConnExec < B , T > + Clone + Unpin ,
624623 T : Read + Write + Unpin ,
625624{
626625 type Output = crate :: Result < Dispatched > ;
0 commit comments