client

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonUserAgents = []string{
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
	"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
	"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
	"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/602.4.8 (KHTML, like Gecko) Version/10.0.3 Safari/602.4.8",
	"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0",
	"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36",
	"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
}

CommonUserAgents contains list of user agents.

Functions

This section is empty.

Types

type Client

type Client struct {
	// User-Agent, used by this client
	UserAgent string
	// HTTP Referer
	Referer string
	// Ray is xray.Ray logger
	Ray xray.Ray

	// Other HTTP headers
	Header map[string]string
	// contains filtered or unexported fields
}

Client represents new HTTP user session

func New

func New() *Client

New creates new HTTP user.

func (*Client) Cookies

func (c *Client) Cookies(url *url.URL) []*http.Cookie

Cookies returns the cookies to send in a request for the given URL. It is up to the implementation to honor the standard cookie use restrictions such as in RFC 6265.

func (*Client) Get

func (c *Client) Get(addr string) (tame.Document, error)

Get performs GET request

func (*Client) GetCookie

func (c *Client) GetCookie(url *url.URL, name string) (string, bool)

GetCookie returns cookie by its name

func (*Client) NewRequest

func (c *Client) NewRequest(method, addr string, body io.Reader) (*http.Request, error)

NewRequest builds and returns new request of desired type with headers injected

func (*Client) SetCookies

func (c *Client) SetCookies(url *url.URL, cookies []*http.Cookie)

SetCookies handles the receipt of the cookies in a reply for the given URL. It may or may not choose to save the cookies, depending on the jar's policy and implementation.

Jump to

Keyboard shortcuts

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