| 1 | package lfshttp |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "net/http" |
| 6 | |
| 7 | "github.com/git-lfs/git-lfs/v3/tools" |
| 8 | "github.com/ssgelm/cookiejarparser" |
| 9 | ) |
| 10 | |
| 11 | func isCookieJarEnabledForHost(c *Client, host string) bool { |
| 12 | _, cookieFileOk := c.uc.Get("http", fmt.Sprintf("https://%v", host), "cookieFile") |
| 13 | |
| 14 | return cookieFileOk |
| 15 | } |
| 16 | |
| 17 | func getCookieJarForHost(c *Client, host string) (http.CookieJar, error) { |
| 18 | cookieFile, _ := c.uc.Get("http", fmt.Sprintf("https://%v", host), "cookieFile") |
| 19 | |
| 20 | cookieFilePath, err := tools.ExpandPath(cookieFile, false) |
| 21 | if err != nil { |
| 22 | return nil, err |
| 23 | } |
| 24 | |
| 25 | return cookiejarparser.LoadCookieJarFile(cookieFilePath) |
| 26 | } |