@@ -62,7 +62,10 @@ impl Response {
6262 pub ( crate ) async fn finish ( & mut self ) -> Result < ( ) > {
6363 let chunks = loop {
6464 match self {
65- Self :: Waiting ( future) => * self = Self :: Loading ( future. await ?) ,
65+ Self :: Waiting ( future) => {
66+ let ( chunks, _summary) = future. await ?;
67+ * self = Self :: Loading ( chunks) ;
68+ }
6669 Self :: Loading ( chunks) => break chunks,
6770 }
6871 } ;
@@ -75,7 +78,7 @@ impl Response {
7578async fn collect_response (
7679 response : HyperResponseFuture ,
7780 compression : Compression ,
78- ) -> Result < Chunks > {
81+ ) -> Result < ( Chunks , Option < Box < QuerySummary > > ) > {
7982 let response = response. await ?;
8083
8184 let status = response. status ( ) ;
@@ -94,11 +97,11 @@ async fn collect_response(
9497 . map ( |value| value. as_bytes ( ) . into ( ) ) ;
9598
9699 let summary = response
97- . headers ( )
98- . get ( "X-ClickHouse-Summary" )
99- . and_then ( |v| v. to_str ( ) . ok ( ) )
100- . and_then ( QuerySummary :: from_header)
101- . map ( Box :: new) ; // More likely to be successful, start streaming.
100+ . headers ( )
101+ . get ( "X-ClickHouse-Summary" )
102+ . and_then ( |v| v. to_str ( ) . ok ( ) )
103+ . and_then ( QuerySummary :: from_header)
104+ . map ( Box :: new) ; // More likely to be successful, start streaming.
102105 // It still can fail, but we'll handle it in `DetectDbException`.
103106 Ok ( ( Chunks :: new ( response. into_body ( ) , compression, tag) , summary) )
104107 } else {
@@ -117,28 +120,6 @@ async fn collect_response(
117120
118121 Err ( error)
119122 }
120-
121- pub ( crate ) fn into_future ( self ) -> ResponseFuture {
122- match self {
123- Self :: Waiting ( future) => future,
124- Self :: Loading ( _) => panic ! ( "response is already streaming" ) ,
125- }
126- }
127-
128- pub ( crate ) async fn finish ( & mut self ) -> Result < ( ) > {
129- let chunks = loop {
130- match self {
131- Self :: Waiting ( future) => {
132- let ( chunks, _summary) = future. await ?;
133- * self = Self :: Loading ( chunks) ;
134- }
135- Self :: Loading ( chunks) => break chunks,
136- }
137- } ;
138-
139- while chunks. try_next ( ) . await ?. is_some ( ) { }
140- Ok ( ( ) )
141- }
142123}
143124
144125#[ cold]
0 commit comments