cookiejarparser

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2021 License: MIT Imports: 10 Imported by: 0

README

cookiejarparser

This is fork of https://github.com/ssgelm/cookiejarparser with custom cookie jar implementation to support ip based cookie setting. 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/jayateertha043/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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadCookieJarFile

func LoadCookieJarFile(path string) (http.CookieJar, error)

LoadCookieJarFile takes a path to a curl (netscape) cookie jar file and crates a go http.CookieJar with the contents

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL