Skip to content

Commit

Permalink
Don’t assume contentType in HTTP headers is set
Browse files Browse the repository at this point in the history
Fixes #50.
  • Loading branch information
filiph committed Nov 17, 2019
1 parent ab2529f commit 2a855fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/src/worker/worker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ Future<ServerInfoUpdate> checkServer(
String content;
try {
Converter<List<int>, String> decoder;
if (response.headers.contentType.charset == latin1.name) {
if (response.headers.contentType?.charset == latin1.name) {
// Some sites still use LATIN-1 for performance reasons.
decoder = latin1.decoder;
} else {
// But if content type is not set or is not LATIN-1, we assume UTF-8.
decoder = utf8.decoder;
}
content = await response.cast<List<int>>().transform(decoder).join();
Expand Down

0 comments on commit 2a855fb

Please sign in to comment.