File tree Expand file tree Collapse file tree 4 files changed +37
-1
lines changed
httpclient/src/main/java/feign/httpclient
okhttp/src/main/java/feign/okhttp Expand file tree Collapse file tree 4 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ public interface Body extends Closeable {
221221 * It is the responsibility of the caller to close the stream.
222222 */
223223 Reader asReader () throws IOException ;
224+
225+ /**
226+ *
227+ */
228+ Reader asReader (Charset charset ) throws IOException ;
224229 }
225230
226231 private static final class InputStreamBody implements Response .Body {
@@ -260,6 +265,12 @@ public Reader asReader() throws IOException {
260265 return new InputStreamReader (inputStream , UTF_8 );
261266 }
262267
268+ @ Override
269+ public Reader asReader (Charset charset ) throws IOException {
270+ checkNotNull (charset , "charset should not be null" );
271+ return new InputStreamReader (inputStream , charset );
272+ }
273+
263274 @ Override
264275 public void close () throws IOException {
265276 inputStream .close ();
@@ -309,6 +320,12 @@ public Reader asReader() throws IOException {
309320 return new InputStreamReader (asInputStream (), UTF_8 );
310321 }
311322
323+ @ Override
324+ public Reader asReader (Charset charset ) throws IOException {
325+ checkNotNull (charset , "charset should not be null" );
326+ return new InputStreamReader (asInputStream (), charset );
327+ }
328+
312329 @ Override
313330 public void close () throws IOException {}
314331
Original file line number Diff line number Diff line change 2121import java .io .IOException ;
2222import java .io .InputStream ;
2323import java .io .Reader ;
24+ import java .nio .charset .Charset ;
2425import java .lang .reflect .InvocationHandler ;
2526import java .lang .reflect .Method ;
2627import java .lang .reflect .Type ;
@@ -399,6 +400,11 @@ public Reader asReader() throws IOException {
399400 return original .body ().asReader ();
400401 }
401402
403+ @ Override
404+ public Reader asReader (Charset charset ) throws IOException {
405+ return original .body ().asReader (charset );
406+ }
407+
402408 @ Override
403409 public void close () throws IOException {
404410 closed .set (true );
Original file line number Diff line number Diff line change 3434import java .io .InputStream ;
3535import java .io .InputStreamReader ;
3636import java .io .Reader ;
37+ import java .nio .charset .Charset ;
3738import java .io .UnsupportedEncodingException ;
3839import java .net .MalformedURLException ;
3940import java .net .URI ;
5253/**
5354 * This module directs Feign's http requests to Apache's
5455 * <a href="https://hc.apache.org/httpcomponents-client-ga/">HttpClient</a>. Ex.
55- *
56+ *
5657 * <pre>
5758 * GitHub github = Feign.builder().client(new ApacheHttpClient()).target(GitHub.class,
5859 * "https://api.github.com");
@@ -224,6 +225,12 @@ public Reader asReader() throws IOException {
224225 return new InputStreamReader (asInputStream (), UTF_8 );
225226 }
226227
228+ @ Override
229+ public Reader asReader (Charset charset ) throws IOException {
230+ Util .checkNotNull (charset , "charset should not be null" );
231+ return new InputStreamReader (asInputStream (), charset );
232+ }
233+
227234 @ Override
228235 public void close () throws IOException {
229236 EntityUtils .consume (entity );
Original file line number Diff line number Diff line change 2222import java .io .IOException ;
2323import java .io .InputStream ;
2424import java .io .Reader ;
25+ import java .nio .charset .Charset ;
2526import java .util .Collection ;
2627import java .util .Map ;
2728import java .util .concurrent .TimeUnit ;
@@ -142,6 +143,11 @@ public InputStream asInputStream() throws IOException {
142143 public Reader asReader () throws IOException {
143144 return input .charStream ();
144145 }
146+
147+ @ Override
148+ public Reader asReader (Charset charset ) throws IOException {
149+ return asReader ();
150+ }
145151 };
146152 }
147153
You can’t perform that action at this time.
0 commit comments