Skip to content

Commit 11003da

Browse files
committed
minor fixes
1 parent cc1aeb6 commit 11003da

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

query.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ func LoadURL(url string) (*html.Node, error) {
109109
reader.Close()
110110
}
111111
}()
112-
113-
switch resp.Header.Get("Content-Encoding") {
112+
encoding := resp.Header.Get("Content-Encoding")
113+
switch encoding {
114114
case "gzip":
115115
reader, err = gzip.NewReader(resp.Body)
116116
if err != nil {
@@ -121,8 +121,10 @@ func LoadURL(url string) (*html.Node, error) {
121121
if err != nil {
122122
return nil, err
123123
}
124-
default:
124+
case "":
125125
reader = resp.Body
126+
default:
127+
return nil, fmt.Errorf("%s compression is not support", encoding)
126128
}
127129

128130
r, err := charset.NewReader(reader, resp.Header.Get("Content-Type"))

0 commit comments

Comments
 (0)