protocol

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiResp

type ApiResp interface {
	Err() error
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(hc plugin.HttpClient) *Client

func (*Client) CallJsonApi

func (c *Client) CallJsonApi(
	url string, qs Params, payload Payload,
	resp ApiResp,
) (err error)

CallJsonApi calls remote HTTP API, and parses its result as JSON.

func (*Client) CallJsonpApi

func (c *Client) CallJsonpApi(url string, qs Params, resp ApiResp) (err error)

func (*Client) CallSecretJsonApi

func (c *Client) CallSecretJsonApi(
	url string, qs Params, payload Payload,
	resp ApiResp, timestamp int64,
) (err error)

CallSecretJsonApi calls JSON API with EC cryptography.

func (*Client) ExportCookies

func (c *Client) ExportCookies(url string) map[string]string

func (*Client) Get

func (c *Client) Get(url string, qs Params, headers map[string]string) (body io.ReadCloser, err error)

func (*Client) GetContent

func (c *Client) GetContent(url string, qs Params) (data []byte, err error)

func (*Client) GetUserAgent

func (c *Client) GetUserAgent() string

func (*Client) ImportCookies

func (c *Client) ImportCookies(cookies map[string]string, domains ...string)

func (*Client) Post

func (c *Client) Post(url string, qs Params, payload Payload) (body io.ReadCloser, err error)

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(name string)

func (*Client) SetupValve

func (c *Client) SetupValve(cdMin, cdMax uint)

func (*Client) Touch

func (c *Client) Touch(url string, qs Params) error

type Params

type Params map[string]string

Params holds parameter pairs.

func (Params) Encode

func (p Params) Encode() string

Encode encodes params into query-string format.

func (Params) ToForm

func (p Params) ToForm() Payload

ToForm converts Params into URL-Encoded form.

func (Params) With

func (p Params) With(name, value string) Params

func (Params) WithArray

func (p Params) WithArray(name string, values []string) Params

func (Params) WithInt

func (p Params) WithInt(name string, value int) Params

func (Params) WithInt64

func (p Params) WithInt64(name string, value int64) Params

func (Params) WithMap

func (p Params) WithMap(name string, value map[string]string) Params

func (Params) WithNow

func (p Params) WithNow(name string) Params

func (Params) WithNowMilli

func (p Params) WithNowMilli(name string) Params

type Payload

type Payload interface {
	io.Reader
	ContentType() string
	ContentLength() int64
}

type Valve

type Valve struct {
	// contains filtered or unexported fields
}

func (*Valve) ClockIn

func (v *Valve) ClockIn()

func (*Valve) Wait

func (v *Valve) Wait()

Jump to

Keyboard shortcuts

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