Documentation ¶
Overview ¶
Package cookiedisk provides to use Netscape cookie file format (cookie.txt).
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadFile ¶
ReadFile read cookies from file
Example ¶
package main import ( "fmt" "io/ioutil" "log" "net/http" "net/http/cookiejar" "net/url" "github.com/kosh04/cookiedisk" ) func main() { rawURL := "http://httpbin.org/cookies" cookies, _ := cookiedisk.ReadFile("testdata/cookie.txt") u, _ := url.Parse(rawURL) jar, _ := cookiejar.New(nil) jar.SetCookies(u, cookies) client := http.Client{Jar: jar} resp, err := client.Get(rawURL) if err != nil { log.Fatal(err) } defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) }
Output: { "cookies": { "k1": "v1" } }
Types ¶
type Entry ¶
type Entry struct { Domain domain TailMatch bool // weather we do tail-matchning of the domain name Path string Secure bool Expires time.Time Name string Value string }
Entry is Netscape cookie format see also: CURL/lib/cookie.c:get_netscape_format()
Click to show internal directories.
Click to hide internal directories.