2222import feign .Request .ProtocolVersion ;
2323import feign .Response ;
2424import feign .Util ;
25- import java .io .ByteArrayInputStream ;
2625import java .io .IOException ;
26+ import java .io .InputStream ;
2727import java .lang .ref .SoftReference ;
2828import java .net .URI ;
2929import java .net .URISyntaxException ;
@@ -97,9 +97,9 @@ public Response execute(Request request, Options options) throws IOException {
9797 }
9898
9999 HttpClient clientForRequest = getOrCreateClient (options );
100- HttpResponse <byte [] > httpResponse ;
100+ HttpResponse <InputStream > httpResponse ;
101101 try {
102- httpResponse = clientForRequest .send (httpRequest , BodyHandlers .ofByteArray ());
102+ httpResponse = clientForRequest .send (httpRequest , BodyHandlers .ofInputStream ());
103103 } catch (final InterruptedException e ) {
104104 Thread .currentThread ().interrupt ();
105105 throw new IOException (e );
@@ -119,19 +119,17 @@ public CompletableFuture<Response> execute(
119119 }
120120
121121 HttpClient clientForRequest = getOrCreateClient (options );
122- CompletableFuture <HttpResponse <byte [] >> future =
123- clientForRequest .sendAsync (httpRequest , HttpResponse .BodyHandlers .ofByteArray ());
122+ CompletableFuture <HttpResponse <InputStream >> future =
123+ clientForRequest .sendAsync (httpRequest , HttpResponse .BodyHandlers .ofInputStream ());
124124 return future .thenApply (httpResponse -> toFeignResponse (request , httpResponse ));
125125 }
126126
127- protected Response toFeignResponse (Request request , HttpResponse <byte [] > httpResponse ) {
127+ protected Response toFeignResponse (Request request , HttpResponse <InputStream > httpResponse ) {
128128 final OptionalLong length = httpResponse .headers ().firstValueAsLong ("Content-Length" );
129129
130130 return Response .builder ()
131131 .protocolVersion (enumForName (ProtocolVersion .class , httpResponse .version ()))
132- .body (
133- new ByteArrayInputStream (httpResponse .body ()),
134- length .isPresent () ? (int ) length .getAsLong () : null )
132+ .body (httpResponse .body (), length .isPresent () ? (int ) length .getAsLong () : null )
135133 .reason (httpResponse .headers ().firstValue ("Reason-Phrase" ).orElse (null ))
136134 .request (request )
137135 .status (httpResponse .statusCode ())
0 commit comments