cookies

package
v0.0.0-...-a833e92 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CookiesToString

func CookiesToString(c Cookies) string

func IsPrint

func IsPrint(s string) bool

IsPrint returns whether s is ASCII and printable according to https://tools.ietf.org/html/rfc20#section-4.2.

func NewCookiesFromString

func NewCookiesFromString(cookieStr string, cookieStruct Cookies) error

Example:

var cookies types.FacebookCookies
err := types.NewCookiesFromString("...", &cookies)

func ReadSetCookiesCustom

func ReadSetCookiesCustom(h http.Header) []*http.Cookie

Custom implementation of std http lib implementation of parsing the Set-Cookie in response headers

Because their implementation can apparently says cookie values that start with " or contain \ are invalid (https://github.com/golang/go/blob/master/src/net/http/cookie.go#L415)

https://github.com/golang/go/blob/master/src/net/http/cookie.go#L60 readSetCookies parses all "Set-Cookie" values from the header h and returns the successfully parsed Cookies.

func ToLower

func ToLower(s string) (lower string, ok bool)

func UpdateFromResponse

func UpdateFromResponse(cookieStruct Cookies, h http.Header)

func UpdateMultipleValues

func UpdateMultipleValues(cookieStruct Cookies, names []string, values []string) error

Make sure the indexes for the names correspond with the correct value they should be set to

func UpdateValue

func UpdateValue(cookieStruct Cookies, name, val string)

Types

type Cookies

type Cookies interface {
	GetValue(name string) string
	GetViewports() (string, string)
	IsLoggedIn() bool
	ToJSON() ([]byte, error)
}

func NewCookiesFromFile

func NewCookiesFromFile(path string, platform types.Platform) (Cookies, error)

FROM JSON FILE.

func NewCookiesFromResponse

func NewCookiesFromResponse(cookies []*http.Cookie) Cookies

type FacebookCookies

type FacebookCookies struct {
	Datr      string `cookie:"datr,omitempty" json:"datr,omitempty"`
	Sb        string `cookie:"sb,omitempty" json:"sb,omitempty"`
	AccountId string `cookie:"c_user,omitempty" json:"c_user,omitempty"`
	Xs        string `cookie:"xs,omitempty" json:"xs,omitempty"`
	Fr        string `cookie:"fr,omitempty" json:"fr,omitempty"`
	Wd        string `cookie:"wd,omitempty" json:"wd,omitempty"`
	Presence  string `cookie:"presence,omitempty" json:"presence,omitempty"`
}

func (*FacebookCookies) GetValue

func (fb *FacebookCookies) GetValue(name string) string

func (*FacebookCookies) GetViewports

func (fb *FacebookCookies) GetViewports() (string, string)

func (*FacebookCookies) IsLoggedIn

func (fb *FacebookCookies) IsLoggedIn() bool

func (*FacebookCookies) ToJSON

func (fb *FacebookCookies) ToJSON() ([]byte, error)

type InstagramCookies

type InstagramCookies struct {
	SessionId  string `cookie:"sessionid,omitempty" json:"SessionId,omitempty"`
	CsrfToken  string `cookie:"csrftoken,omitempty" json:"CsrfToken,omitempty"`
	MachineId  string `cookie:"mid,omitempty" json:"MachineId,omitempty"`
	IgDeviceId string `cookie:"ig_did,omitempty" json:"IgDeviceId,omitempty"`
	Rur        string `cookie:"rur,omitempty" json:"Rur,omitempty"`
	UserId     string `cookie:"ds_user_id,omitempty" json:"UserId,omitempty"`
	ShbId      string `cookie:"shbid,omitempty" json:"ShbId,omitempty"`
	Shbts      string `cookie:"shbts,omitempty" json:"Shbts,omitempty"`
	IgWWWClaim string `json:"IgWWWClaim,omitempty"`
}

func (*InstagramCookies) GetValue

func (ig *InstagramCookies) GetValue(name string) string

func (*InstagramCookies) GetViewports

func (ig *InstagramCookies) GetViewports() (string, string)

func (*InstagramCookies) IsLoggedIn

func (ig *InstagramCookies) IsLoggedIn() bool

func (*InstagramCookies) ToJSON

func (ig *InstagramCookies) ToJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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