diff options
Diffstat (limited to 'async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala')
-rw-r--r-- | async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala b/async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala index 39c2b30..885e5a9 100644 --- a/async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala +++ b/async-http-client-backend/src/main/scala/com/softwaremill/sttp/asynchttpclient/AsyncHttpClientBackend.scala @@ -270,7 +270,10 @@ abstract class AsyncHttpClientBackend[R[_], S](asyncHttpClient: AsyncHttpClient, Try(()) case ResponseAsString(enc) => - Try(response.getResponseBody(Charset.forName(enc))) + val charset = Option(response.getHeader(ContentTypeHeader)) + .flatMap(encodingFromContentType) + .getOrElse(enc) + Try(response.getResponseBody(Charset.forName(charset))) case ResponseAsByteArray => Try(response.getResponseBodyAsBytes) |