@@ -11,13 +11,7 @@ use crate::error::{Error, Result};
11
11
use crate :: service:: ServiceMethod ;
12
12
use crate :: status:: { Code , Status } ;
13
13
use crate :: {
14
- finalize_decompression,
15
- StreamingApi ,
16
- StreamingApiReceiver ,
17
- CONNECT_PROTOCOL_VERSION ,
18
- CONTENT_ENCODING_SNAPPY ,
19
- GRPC_STATUS ,
20
- TRANSFER_ENCODING_TRAILERS ,
14
+ finalize_decompression, BodyFramer , SingleFrame , StreamingApi , StreamingApiReceiver , CONNECT_PROTOCOL_VERSION , CONTENT_ENCODING_SNAPPY , GRPC_STATUS , TRANSFER_ENCODING_TRAILERS
21
15
} ;
22
16
use assert_matches:: debug_assert_matches;
23
17
use axum:: body:: Body ;
@@ -32,8 +26,10 @@ use bd_grpc_codec::{
32
26
GRPC_ENCODING_HEADER ,
33
27
} ;
34
28
use bd_time:: TimeDurationExt ;
29
+ use futures:: StreamExt ;
35
30
use http:: header:: { CONTENT_ENCODING , CONTENT_TYPE , TRANSFER_ENCODING } ;
36
31
use http:: { HeaderMap , Uri } ;
32
+ use http_body:: Frame ;
37
33
use http_body_util:: { BodyExt , StreamBody } ;
38
34
use hyper:: body:: Incoming ;
39
35
use hyper_util:: client:: legacy:: connect:: { Connect , HttpConnector } ;
@@ -296,9 +292,13 @@ impl<C: Connect + Clone + Send + Sync + 'static> Client<C> {
296
292
validate : bool ,
297
293
compression : Option < bd_grpc_codec:: Compression > ,
298
294
optimize_for : OptimizeFor ,
299
- ) -> Result < StreamingApi < OutgoingType , IncomingType > > {
295
+ ) -> Result < StreamingApi < OutgoingType , IncomingType , BodyFramer > > {
300
296
let ( tx, rx) = mpsc:: channel ( 1 ) ;
301
- let body = StreamBody :: new ( ReceiverStream :: new ( rx) ) ;
297
+ let body = StreamBody :: new ( ReceiverStream :: new ( rx) . map ( |f| match f {
298
+ Ok ( SingleFrame :: Data ( data) ) => Ok ( Frame :: data ( data) ) ,
299
+ Ok ( SingleFrame :: Trailers ( trailers) ) => Ok ( Frame :: trailers ( trailers) ) ,
300
+ Err ( e) => Err ( e) ,
301
+ } ) ) ;
302
302
303
303
match compression {
304
304
None => { } ,
@@ -347,7 +347,7 @@ impl<C: Connect + Clone + Send + Sync + 'static> Client<C> {
347
347
validate : bool ,
348
348
optimize_for : OptimizeFor ,
349
349
connect_protocol : Option < ConnectProtocolType > ,
350
- ) -> Result < StreamingApiReceiver < IncomingType > > {
350
+ ) -> Result < StreamingApiReceiver < IncomingType , BodyFramer > > {
351
351
let mut encoder = Encoder :: new ( None ) ;
352
352
let response = self
353
353
. common_request (
@@ -360,7 +360,9 @@ impl<C: Connect + Clone + Send + Sync + 'static> Client<C> {
360
360
let ( parts, body) = response. into_parts ( ) ;
361
361
Ok ( StreamingApiReceiver :: new (
362
362
parts. headers ,
363
- Body :: new ( body) ,
363
+ BodyFramer {
364
+ body : Body :: new ( body) ,
365
+ } ,
364
366
validate,
365
367
optimize_for,
366
368
None ,
0 commit comments