Skip to content

Commit 8a6dc1e

Browse files
authored
golang.org/x/net 0.8.0 => 0.9.0, cookies fix (#56)
1 parent 3c672bd commit 8a6dc1e

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ go 1.20
55
require (
66
github.com/s0rg/compflag v1.1.0
77
github.com/s0rg/set v1.0.0
8-
golang.org/x/net v0.8.0
8+
golang.org/x/net v0.9.0
99
)

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ github.com/s0rg/compflag v1.1.0 h1:xhCUPLy+5Ue/Q9I/nIcLti2Ul6P42JYx4UvtYoDXmlQ=
22
github.com/s0rg/compflag v1.1.0/go.mod h1:XMntVpc3+jpmBe0s8xo4w9swH8T9ARGkMC9HFiDRoUw=
33
github.com/s0rg/set v1.0.0 h1:/MAmKEQ3Ltodli7/+e8iSTKNwhzmvxkmSDZO8BMTFbE=
44
github.com/s0rg/set v1.0.0/go.mod h1:n2TtovR+7TrBIztw+6muV9ZLRuDIimsd8YyTN+QBmHQ=
5-
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
6-
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
5+
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
6+
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=

pkg/client/cookie.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package client
33
import (
44
"log"
55
"net/http"
6-
"net/url"
76
"strings"
87
)
98

@@ -37,25 +36,15 @@ func parseOne(raw string) (rv *http.Cookie, ok bool) {
3736
return
3837
}
3938

40-
var name, value string
39+
var name string
4140

4241
if name = strings.TrimSpace(pair[0]); name == "" {
4342
return
4443
}
4544

46-
value = strings.TrimSpace(pair[1])
47-
48-
if value != "" {
49-
var err error
50-
51-
if value, err = url.QueryUnescape(value); err != nil {
52-
return
53-
}
54-
}
55-
5645
rv = &http.Cookie{
5746
Name: name,
58-
Value: value,
47+
Value: strings.TrimSpace(pair[1]),
5948
}
6049

6150
return rv, true

pkg/client/cookie_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func Test_prepareCookies(t *testing.T) {
1919
[]string{"NAME1=VALUE1;NAME2=ENCODED%20VALUE;", "NAME3=VALUE3"},
2020
[]*http.Cookie{
2121
{Name: "NAME1", Value: "VALUE1"},
22-
{Name: "NAME2", Value: "ENCODED VALUE"},
22+
{Name: "NAME2", Value: "ENCODED%20VALUE"},
2323
{Name: "NAME3", Value: "VALUE3"},
2424
},
2525
},
@@ -42,7 +42,7 @@ func Test_prepareCookies(t *testing.T) {
4242
got := prepareCookies(tt.args)
4343

4444
if len(got) != len(tt.want) {
45-
t.Errorf("prepareCookies() invalid rusult count for: %v", tt.want)
45+
t.Errorf("prepareCookies() invalid result count for: %v", tt.want)
4646
}
4747

4848
if len(got) == 0 {

pkg/client/http_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ const (
1515
func TestHTTPGetOK(t *testing.T) {
1616
t.Parallel()
1717

18-
c := New(ua, 1, false, []string{"FOO: BAR"}, []string{"NAME=ENCODED%20VAL"})
18+
c := New(ua, 1, false, []string{"FOO: BAR"}, []string{"NAME=VALUE"})
1919

2020
const (
2121
body = "test-body"
22-
cookie = "ENCODED VAL"
22+
cookie = "VALUE"
2323
)
2424

2525
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)