util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCookie

func CleanCookie(url *url.URL) error

func DELETE

func DELETE(u string, opts ...Option) (raw json.RawMessage, err error)

func Dir

func Dir() string

func File

func File(u, method string, opts ...Option) (io io.Reader, err error)

func Fnv

func Fnv(msg string) uint64

func GET

func GET(u string, opts ...Option) (raw json.RawMessage, err error)

func GetCookie

func GetCookie(url *url.URL, name string) *http.Cookie

func GetCookies

func GetCookies(url *url.URL) []*http.Cookie
func HEAD(u string, opts ...Option) (raw json.RawMessage, err error)

func Hash

func Hash(key, msg string) string

func Is

func Is(s string) bool

Is returns whether s is ASCII.

func IsPrint

func IsPrint(s string) bool

func MD5

func MD5(msg string) []byte

func PATCH

func PATCH(u string, opts ...Option) (raw json.RawMessage, err error)

func POST

func POST(u string, opts ...Option) (raw json.RawMessage, err error)

func PUT

func PUT(u string, opts ...Option) (raw json.RawMessage, err error)

func ReadFile

func ReadFile(filepath string, data interface{}) error

func RegisterConnTimeout

func RegisterConnTimeout(timeout, longTimeout time.Duration)

func RegisterCookieFun

func RegisterCookieFun(name string)

func RegisterCookieJar

func RegisterCookieJar(name string)

func RegisterDNS

func RegisterDNS(dns []string)

func RegisterDNSTimeout

func RegisterDNSTimeout(timeout time.Duration)

func RegisterDialerTimeout

func RegisterDialerTimeout(timeout time.Duration)

func RegisterInitCookie

func RegisterInitCookie(name, cookie, endpoint string)

func RegisterProxy

func RegisterProxy(proxy func(*http.Request) (*url.URL, error))

func Request

func Request(method, u string, opts ...Option) (json.RawMessage, http.Header, error)

func SetCookie

func SetCookie(url *url.URL, name, value string)

func Sha256

func Sha256(msg string) string

func ToLower

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

ToLower returns the lowercase version of s if s is ASCII and printable.

func UserAgent

func UserAgent(args ...int) string

func WriteFile

func WriteFile(filepath string, data interface{}) error

Types

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

func WithClientCookieFun

func WithClientCookieFun(name string) ClientOption

func WithClientCookieJar

func WithClientCookieJar(name string) ClientOption

func WithClientDNS

func WithClientDNS(dns []string) ClientOption

func WithClientProxy

func WithClientProxy(proxy func(*http.Request) (*url.URL, error)) ClientOption

func WithConnTimeout

func WithConnTimeout(timeout, longTimeout time.Duration) ClientOption

func WithDNSTimeout

func WithDNSTimeout(timeout time.Duration) ClientOption

func WithDialerTimeout

func WithDialerTimeout(timeout time.Duration) ClientOption

func WithInitClientCookie

func WithInitClientCookie(name, cookie, endpoint string) ClientOption

type CodeError

type CodeError struct {
	Method  string
	URL     string
	Code    int
	Message string
}

func (CodeError) Error

func (err CodeError) Error() string

type CustomerCookie

type CustomerCookie interface {
	Cookies(req *http.Request)
	SetCookies(u *url.URL, resp *http.Response)
}

type EmbedClient

type EmbedClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) *EmbedClient

func (*EmbedClient) CleanCookie

func (c *EmbedClient) CleanCookie(u *url.URL) error

func (*EmbedClient) DELETE

func (c *EmbedClient) DELETE(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) File

func (c *EmbedClient) File(u, method string, opts ...Option) (io io.Reader, err error)

func (*EmbedClient) GET

func (c *EmbedClient) GET(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) GetCookie

func (c *EmbedClient) GetCookie(url *url.URL, name string) *http.Cookie

func (*EmbedClient) GetCookies

func (c *EmbedClient) GetCookies(url *url.URL) []*http.Cookie

func (*EmbedClient) HEAD

func (c *EmbedClient) HEAD(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) PATCH

func (c *EmbedClient) PATCH(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) POST

func (c *EmbedClient) POST(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) PUT

func (c *EmbedClient) PUT(u string, opts ...Option) (raw json.RawMessage, err error)

func (*EmbedClient) Request

func (c *EmbedClient) Request(method, u string, opts ...Option) (json.RawMessage, http.Header, error)

func (*EmbedClient) SetCookie

func (c *EmbedClient) SetCookie(u *url.URL, name, value string)

type Jar

type Jar struct {
	PsList cookiejar.PublicSuffixList `json:"pslist"`

	// mu locks the remaining fields.
	Mu sync.Mutex `json:"mu"`

	// entries is a set of entries, keyed by their eTLD+1 and subkeyed by
	// their name/domain/path.
	Entries map[string]map[string]entry `json:"entries"`

	// nextSeqNum is the next sequence number assigned to a new cookie
	// created SetCookies.
	NextSeqNum uint64 `json:"nextseqnum"`
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithAfterResponse

func WithAfterResponse(f func(w *http.Response)) Option

func WithBeforeRequest

func WithBeforeRequest(f func(r *http.Request)) Option

func WithBody

func WithBody(body interface{}) Option

func WithCacheDebug

func WithCacheDebug(periodMS ...int64) Option

func WithContext

func WithContext(ctx context.Context) Option

func WithDebug deprecated

func WithDebug() Option

Deprecated: this method is currently unused. It is use new replace

WithDump()

func WithDump

func WithDump() Option

func WithHeader

func WithHeader(header map[string]string) Option

func WithProxy

func WithProxy(f func(*http.Request) (*url.URL, error)) Option

func WithProxyDail

func WithProxyDail(f func(ctx context.Context, network, addr string) (net.Conn, error)) Option

func WithRandomHost

func WithRandomHost(f func(string) string) Option

func WithRetry

func WithRetry(retry uint) Option

func WithTest deprecated

func WithTest(periodMS ...int64) Option

Deprecated: this method is currently unused. It is use new replace

WithCacheDebug()

Source Files

  • client.go
  • client_option.go
  • conn.go
  • cookie.go
  • entry_1.23.go
  • hash.go
  • init.go
  • request_option.go

Jump to

Keyboard shortcuts

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