/
View dependency graph
Depends on
- dh-golang (dh-golang)
- golang-defaults (golang-any)
- golang-golang-x-net (golang-golang-x-net-dev)
- debhelper-compat
Used by
README (full)
cookiejarparser
cookiejarparser is a Go library that parses a curl (netscape) cookiejar file into a Go http.CookieJar.
Usage
Assuming you have a netscape/curl style cookie jar made with something like:
$ curl -c cookies.txt -v https://github.com
That cookiejar can be used when making a web request using the following code:
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"github.com/ssgelm/cookiejarparser"
)
func main() {
cookies, err := cookiejarparser.LoadCookieJarFile("cookies.txt")
if err != nil {
log.Fatal(err)
}
client := &http.Client{
Jar: cookies,
}
resp, err := client.Get("https://github.com")
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
respData, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(respData))
}
License
MIT
| dir | data/ |
| dir | debian/ |
| file | LICENSE.md |
| file | README.md |
| file | cookiejarparser.go |
| file | cookiejarparser_test.go |
| file | go.mod |
| file | go.sum |