Convert feed encoding only if the charset is specified
This commit is contained in:
parent
855fb06bc9
commit
99dfbdbb47
1 changed files with 10 additions and 3 deletions
|
@ -4,8 +4,12 @@
|
||||||
|
|
||||||
package http
|
package http
|
||||||
|
|
||||||
import "io"
|
import (
|
||||||
import "golang.org/x/net/html/charset"
|
"io"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/net/html/charset"
|
||||||
|
)
|
||||||
|
|
||||||
// Response wraps a server response.
|
// Response wraps a server response.
|
||||||
type Response struct {
|
type Response struct {
|
||||||
|
@ -41,5 +45,8 @@ func (r *Response) IsModified(etag, lastModified string) bool {
|
||||||
|
|
||||||
// NormalizeBodyEncoding make sure the body is encoded in UTF-8.
|
// NormalizeBodyEncoding make sure the body is encoded in UTF-8.
|
||||||
func (r *Response) NormalizeBodyEncoding() (io.Reader, error) {
|
func (r *Response) NormalizeBodyEncoding() (io.Reader, error) {
|
||||||
return charset.NewReader(r.Body, r.ContentType)
|
if strings.Contains(r.ContentType, "charset=") {
|
||||||
|
return charset.NewReader(r.Body, r.ContentType)
|
||||||
|
}
|
||||||
|
return r.Body, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue