Description
Rod Version: v0.116.2
中文省流:如果在 rod cookie (a) 转 go http cookie (b) 的时候直接 b.Expires = a.Expires.Time()
的话,http 这边发请求时所有的 session cookie 就都没了。因为 rod session cookie 的值是 -1 而不是 0,转成 time 就成了 23:59:59 这样的值了。
proto.NetworkCookie.Expires
(line 969) is a TimeSinceEpoch field.
Lines 954 to 969 in 3025dde
TimeSinceEpoch.Time
maps a TimeSinceEpoch value to time.Time value.
Lines 14 to 22 in 3025dde
Please note the line 14, "For session cookie, the value should be -1. ". So when a cookie is a session cookie, the result will be unix(0) - 1("1969-12-31 23:59:59"). When you are using some codes like below:
func CookieFrom(c *proto.NetworkCookie) *http.Cookie {
hc := &http.Cookie{
Name: c.Name,
Value: c.Value,
Quoted: false,
Path: c.Path,
Domain: c.Domain,
Expires: c.Expires.Time(), // <--
RawExpires: "",
MaxAge: 0,
Secure: c.Secure,
HttpOnly: c.HTTPOnly,
SameSite: SameSite(c.SameSite),
Partitioned: false,
Raw: "",
Unparsed: []string{},
}
return hc
}
You will loss all session cookie when you're sending requests. Because hc.Expires is not a zero value and it has expired.
Activity