Skip to content

Commit

Permalink
Merge pull request flutter#2314 from collinjackson/chokes
Browse files Browse the repository at this point in the history
fixes flutter#1461 oknet chokes on binary charsets
  • Loading branch information
collinjackson committed Jan 29, 2016
2 parents 7e7df7f + 57b1785 commit e49d611
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sky/services/oknet/src/org/domokit/oknet/UrlLoaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel;
import java.nio.charset.Charset;
import java.nio.charset.UnsupportedCharsetException;
import java.util.concurrent.Executor;

import okio.BufferedSource;
Expand Down Expand Up @@ -248,9 +249,13 @@ public void onResponse(Response response) {
MediaType mediaType = body.contentType();
if (mediaType != null) {
urlResponse.mimeType = mediaType.type() + "/" + mediaType.subtype();
Charset charset = mediaType.charset();
if (charset != null) {
urlResponse.charset = charset.displayName();
try {
Charset charset = mediaType.charset();
if (charset != null) {
urlResponse.charset = charset.displayName();
}
} catch (UnsupportedCharsetException e) {
Log.e(TAG, "Unsupported charset", e);
}
}

Expand Down

0 comments on commit e49d611

Please sign in to comment.