aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--http/client/response.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/http/client/response.go b/http/client/response.go
index 61a9704..0e918b5 100644
--- a/http/client/response.go
+++ b/http/client/response.go
@@ -11,6 +11,7 @@ import (
"mime"
"regexp"
"strings"
+ "unicode/utf8"
"golang.org/x/net/html/charset"
)
@@ -97,6 +98,12 @@ func (r *Response) EnsureUnicodeBody() (err error) {
if xmlEncodingRegex.Match(buffer[0:length]) {
return
}
+
+ // If no encoding is specified in the XML prolog and
+ // the document is valid UTF-8, nothing needs to be done.
+ if utf8.Valid(buffer) {
+ return
+ }
}
}