httpclient

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultClient    *http.Client  = NewTimeoutClient(10*time.Second, 10*time.Second)
	DnsCacheDuration time.Duration = 0
)

Functions

func Do

func Do(req *http.Request) (*http.Response, error)

func DoGet

func DoGet(urlStr string, params url.Values) ([]byte, error)

func DoGetEx

func DoGetEx(urlStr string, params url.Values, p interface{}) error

func DoJsonPost

func DoJsonPost(urlStr string, param interface{}) ([]byte, error)

func DoMultiPartPost

func DoMultiPartPost(urlStr string, params url.Values, files url.Values) ([]byte, error)

func DoMultiPartPostEx

func DoMultiPartPostEx(urlStr string, params url.Values, files url.Values, p interface{}) error

func DoPost

func DoPost(urlStr string, params url.Values) ([]byte, error)

func DoPostEx

func DoPostEx(urlStr string, params url.Values, p interface{}) error

func DoRequest

func DoRequest(urlStr string) ([]byte, error)

func NewTimeoutClient

func NewTimeoutClient(connectTimeout time.Duration, readWriteTimeout time.Duration) *http.Client

func TimeoutDialer

func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)

Types

type DnsCache

type DnsCache struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*DnsCache) Get

func (this *DnsCache) Get(addr string) string

the cache will not remove without a trigger of http get

type DnsCacheItem

type DnsCacheItem struct {
	IP        string
	CacheTime int64
}

type TimeoutConn

type TimeoutConn struct {
	net.Conn
	// contains filtered or unexported fields
}

func NewTimeoutConn

func NewTimeoutConn(conn net.Conn, timeout time.Duration) *TimeoutConn

func (*TimeoutConn) Read

func (c *TimeoutConn) Read(b []byte) (n int, err error)

func (*TimeoutConn) Write

func (c *TimeoutConn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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