Fix overwrite of existing cookiejar.

This commit is contained in:
y a t s
2026-06-18 10:02:16 -04:00
parent 1e9bd059f0
commit 72840af90e
5 changed files with 64 additions and 31 deletions
+11 -11
View File
@@ -21,25 +21,25 @@ type KF struct {
}
// Supply your own http.Client to route through any proxies.
func NewKF(hc http.Client, host *url.URL) (*KF, error) {
func NewKF(hc http.Client, host *url.URL) (KF, error) {
u, err := url.Parse(fmt.Sprintf("https://%s", host.Hostname()))
if err != nil {
return nil, err
return KF{}, err
}
jar, err := cookiejar.New(nil)
if err != nil {
return nil, err
if hc.Jar == nil {
jar, err := cookiejar.New(nil)
if err != nil {
return KF{}, err
}
hc.Jar = jar
}
hc.Jar = jar
kf := &KF{
return KF{
client: hc,
domain: u,
}
return kf, nil
}, nil
}
type User struct {