File tree 1 file changed +13
-8
lines changed
spring-web/src/main/java/org/springframework/http/client
1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change 20
20
import java .io .InputStream ;
21
21
import java .time .Duration ;
22
22
23
+ import io .netty .buffer .ByteBuf ;
24
+ import org .reactivestreams .FlowAdapters ;
23
25
import reactor .netty .Connection ;
24
26
import reactor .netty .http .client .HttpClientResponse ;
25
27
@@ -79,19 +81,22 @@ public InputStream getBody() throws IOException {
79
81
if (body != null ) {
80
82
return body ;
81
83
}
82
-
83
84
try {
84
- body = this .connection .inbound ().receive ().aggregate ().asInputStream ().block (this .readTimeout );
85
+ SubscriberInputStream <ByteBuf > is = new SubscriberInputStream <>(
86
+ byteBuf -> {
87
+ byte [] bytes = new byte [byteBuf .readableBytes ()];
88
+ byteBuf .readBytes (bytes );
89
+ byteBuf .release ();
90
+ return bytes ;
91
+ },
92
+ ByteBuf ::release , 16 );
93
+ this .connection .inbound ().receive ().retain ().subscribe (FlowAdapters .toSubscriber (is ));
94
+ this .body = is ;
95
+ return is ;
85
96
}
86
97
catch (RuntimeException ex ) {
87
98
throw ReactorClientHttpRequest .convertException (ex );
88
99
}
89
-
90
- if (body == null ) {
91
- body = InputStream .nullInputStream ();
92
- }
93
- this .body = body ;
94
- return body ;
95
100
}
96
101
97
102
@ Override
You can’t perform that action at this time.
0 commit comments