git-lfs/lfshttp/cookies.go
Stephen Gelman 72f3f168d2 Use different parser for cookiejar files
The original parser that was used in #3825 brings in a lot of
dependencies that complicate packaging git-lfs.  This replaces it with a
small parser I wrote with almost no dependencies.  I've tested this as
extensively as i can and it seems to work correctly.
2019-10-27 16:48:15 -05:00

27 lines
610 B
Go

package lfshttp
import (
"fmt"
"net/http"
"github.com/git-lfs/git-lfs/tools"
"github.com/ssgelm/cookiejarparser"
)
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) {
cookieFile, _ := c.uc.Get("http", fmt.Sprintf("https://%v", host), "cookieFile")
cookieFilePath, err := tools.ExpandPath(cookieFile, false)
if err != nil {
return nil, err
}
return cookiejarparser.LoadCookieJarFile(cookieFilePath)
}