2019-09-18 16:14:02 +00:00
|
|
|
package lfshttp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
|
2021-09-01 19:41:10 +00:00
|
|
|
"github.com/git-lfs/git-lfs/v3/tools"
|
2019-10-27 21:48:15 +00:00
|
|
|
"github.com/ssgelm/cookiejarparser"
|
2019-09-18 16:14:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func isCookieJarEnabledForHost(c *Client, host string) bool {
|
|
|
|
_, cookieFileOk := c.uc.Get("http", fmt.Sprintf("https://%v", host), "cookieFile")
|
|
|
|
|
|
|
|
return cookieFileOk
|
|
|
|
}
|
|
|
|
|
|
|
|
func getCookieJarForHost(c *Client, host string) (http.CookieJar, error) {
|
2019-09-22 09:58:08 +00:00
|
|
|
cookieFile, _ := c.uc.Get("http", fmt.Sprintf("https://%v", host), "cookieFile")
|
2019-09-18 16:14:02 +00:00
|
|
|
|
2019-09-22 09:58:33 +00:00
|
|
|
cookieFilePath, err := tools.ExpandPath(cookieFile, false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-10-27 21:48:15 +00:00
|
|
|
return cookiejarparser.LoadCookieJarFile(cookieFilePath)
|
2019-09-18 16:14:02 +00:00
|
|
|
}
|