v0.0.0-...-5c12a10 Latest Latest

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

Go to latest
Published: Jun 10, 2022 License: MIT Imports: 23 Imported by: 0




This section is empty.


View Source
var (
	DefaultConnections    = 10000
	DefaultName           = "isucandar"
	DefaultAccept         = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
	DefaultRequestTimeout = 1 * time.Second

	DefaultTLSConfig = &tls.Config{
		InsecureSkipVerify: true,

	DefaultDialer    *net.Dialer
	DefaultTransport *http.Transport
View Source
var (
	ErrTransportInvalid       = errors.New("Specify transport option(WithCloneTransport or WithDefaultTransport)")
	ErrUnknownContentEncoding = errors.New("Unknown content encoding")


This section is empty.


type Agent

type Agent struct {
	Name          string
	BaseURL       *url.URL
	DefaultAccept string
	CacheStore    CacheStore
	HttpClient    *http.Client

func NewAgent

func NewAgent(opts ...AgentOption) (*Agent, error)

func (*Agent) ClearCookie

func (a *Agent) ClearCookie()

func (*Agent) DELETE

func (a *Agent) DELETE(target string, body io.Reader) (*http.Request, error)

func (*Agent) Do

func (a *Agent) Do(ctx context.Context, req *http.Request) (*http.Response, error)

func (*Agent) GET

func (a *Agent) GET(target string) (*http.Request, error)

func (*Agent) NewRequest

func (a *Agent) NewRequest(method string, target string, body io.Reader) (*http.Request, error)

func (*Agent) PATCH

func (a *Agent) PATCH(target string, body io.Reader) (*http.Request, error)

func (*Agent) POST

func (a *Agent) POST(target string, body io.Reader) (*http.Request, error)

func (*Agent) PUT

func (a *Agent) PUT(target string, body io.Reader) (*http.Request, error)

func (*Agent) ProcessHTML

func (a *Agent) ProcessHTML(ctx context.Context, r *http.Response, body io.ReadCloser) (Resources, error)

type AgentOption

type AgentOption func(*Agent) error

func WithBaseURL

func WithBaseURL(base string) AgentOption

func WithCloneTransport

func WithCloneTransport(trs *http.Transport) AgentOption

func WithDefaultTransport

func WithDefaultTransport() AgentOption

func WithNoCache

func WithNoCache() AgentOption

func WithNoCookie

func WithNoCookie() AgentOption

func WithTimeout

func WithTimeout(d time.Duration) AgentOption

func WithTransport

func WithTransport(trs *http.Transport) AgentOption

func WithUserAgent

func WithUserAgent(ua string) AgentOption

type Cache

type Cache struct {
	ReqDirectives *cacheobject.RequestCacheDirectives
	ResDirectives *cacheobject.ResponseCacheDirectives
	Expires       *time.Time
	Date          *time.Time
	LastModified  *time.Time
	ETag          *string
	Varies        []string
	VariesKey     string
	// contains filtered or unexported fields

func (*Cache) Body

func (c *Cache) Body() []byte

type CacheStore

type CacheStore interface {
	Get(*http.Request) *Cache
	Put(*http.Request, *Cache)

func NewCacheStore

func NewCacheStore() CacheStore

type Resource

type Resource struct {
	InitiatorType string
	Request       *http.Request
	Response      *http.Response
	Error         error

type Resources

type Resources map[string]*Resource

Jump to

Keyboard shortcuts

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