Documentation ¶
Index ¶
- Variables
- func AESCBCDecrypt(cipherText, key []byte, iv ...byte) ([]byte, error)
- func AESCBCEncrypt(plainText, key []byte, iv ...byte) ([]byte, error)
- func DecodeBytesToUint32(b []byte) uint32
- func EncodeUint32ToBytes(i uint32) []byte
- func FormatMap2XML(m WXML) (string, error)
- func HMAC(algo HashAlgo, s, key string) string
- func Hash(algo HashAlgo, s string) string
- func MD5(s string) string
- func NonceStr() string
- func PKCS7Padding(cipherText []byte, blockSize int) []byte
- func PKCS7UnPadding(plainText []byte, blockSize int) []byte
- func RSADecrypt(cipherText, privateKey []byte) ([]byte, error)
- func RSAEncrypt(data, publicKey []byte) ([]byte, error)
- func RandomStr(n int) string
- func SHA1(s string) string
- type CDATA
- type HTTPClient
- func (h *HTTPClient) Get(url string, options ...HTTPRequestOption) ([]byte, error)
- func (h *HTTPClient) GetXML(uri string, body WXML, options ...HTTPRequestOption) (WXML, error)
- func (h *HTTPClient) Post(url string, body []byte, options ...HTTPRequestOption) ([]byte, error)
- func (h *HTTPClient) PostXML(url string, body WXML, options ...HTTPRequestOption) (WXML, error)
- type HTTPClientOption
- func WithHTTPDefaultTimeout(d time.Duration) HTTPClientOption
- func WithHTTPDialFallbackDelay(d time.Duration) HTTPClientOption
- func WithHTTPDialKeepAlive(d time.Duration) HTTPClientOption
- func WithHTTPDialTimeout(d time.Duration) HTTPClientOption
- func WithHTTPExpectContinueTimeout(d time.Duration) HTTPClientOption
- func WithHTTPIdleConnTimeout(d time.Duration) HTTPClientOption
- func WithHTTPMaxConnsPerHost(n int) HTTPClientOption
- func WithHTTPMaxIdleConns(n int) HTTPClientOption
- func WithHTTPMaxIdleConnsPerHost(n int) HTTPClientOption
- func WithHTTPTLSConfig(c *tls.Config) HTTPClientOption
- func WithHTTPTLSHandshakeTimeout(d time.Duration) HTTPClientOption
- type HTTPRequestOption
- type HashAlgo
- type WXML
- type X
Constants ¶
This section is empty.
Variables ¶
var BufPool = &bufferPool{pool: sync.Pool{ New: func() interface{} { return bytes.NewBuffer(make([]byte, 0, 4<<10)) }, }}
BufPool buffer pool
var DefaultHTTPClient = &HTTPClient{ client: &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyFromEnvironment, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 60 * time.Second, }).DialContext, MaxIdleConns: 0, MaxIdleConnsPerHost: 1000, MaxConnsPerHost: 1000, IdleConnTimeout: 60 * time.Second, TLSHandshakeTimeout: 10 * time.Second, ExpectContinueTimeout: 1 * time.Second, }, }, timeout: defaultHTTPTimeout, }
DefaultHTTPClient default http client
Functions ¶
func AESCBCDecrypt ¶
AESCBCDecrypt AES CBC decrypt with PKCS#7 unpadding
func AESCBCEncrypt ¶
AESCBCEncrypt AES CBC encrypt with PKCS#7 padding
func DecodeBytesToUint32 ¶
DecodeBytesToUint32 从 4 字节的网络字节序里解析出整数 uint32
func EncodeUint32ToBytes ¶
EncodeUint32ToBytes 把整数 uint32 格式化成 4 字节的网络字节序
func PKCS7Padding ¶
PKCS7Padding PKCS#7 padding
func PKCS7UnPadding ¶
PKCS7UnPadding PKCS#7 unpadding
func RSADecrypt ¶ added in v1.1.0
RSADecrypt rsa decrypt with private key
func RSAEncrypt ¶ added in v1.1.0
RSAEncrypt rsa encrypt with public key
Types ¶
type CDATA ¶
type CDATA string
CDATA XML CDATA section which is defined as blocks of text that are not parsed by the parser, but are otherwise recognized as markup.
func (CDATA) MarshalXML ¶
MarshalXML encodes the receiver as zero or more XML elements.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient http client
func NewHTTPClient ¶
func NewHTTPClient(options ...HTTPClientOption) *HTTPClient
NewHTTPClient returns a new http client
func (*HTTPClient) Get ¶
func (h *HTTPClient) Get(url string, options ...HTTPRequestOption) ([]byte, error)
Get http get request
func (*HTTPClient) GetXML ¶
func (h *HTTPClient) GetXML(uri string, body WXML, options ...HTTPRequestOption) (WXML, error)
GetXML http xml get request
func (*HTTPClient) Post ¶
func (h *HTTPClient) Post(url string, body []byte, options ...HTTPRequestOption) ([]byte, error)
Post http post request
func (*HTTPClient) PostXML ¶
func (h *HTTPClient) PostXML(url string, body WXML, options ...HTTPRequestOption) (WXML, error)
PostXML http xml post request
type HTTPClientOption ¶
type HTTPClientOption interface {
// contains filtered or unexported methods
}
HTTPClientOption configures how we set up the http client
func WithHTTPDefaultTimeout ¶
func WithHTTPDefaultTimeout(d time.Duration) HTTPClientOption
WithHTTPDefaultTimeout specifies the `DefaultTimeout` to http client.
func WithHTTPDialFallbackDelay ¶
func WithHTTPDialFallbackDelay(d time.Duration) HTTPClientOption
WithHTTPDialFallbackDelay specifies the `FallbackDelay` to net.Dialer.
func WithHTTPDialKeepAlive ¶
func WithHTTPDialKeepAlive(d time.Duration) HTTPClientOption
WithHTTPDialKeepAlive specifies the `KeepAlive` to net.Dialer.
func WithHTTPDialTimeout ¶
func WithHTTPDialTimeout(d time.Duration) HTTPClientOption
WithHTTPDialTimeout specifies the `DialTimeout` to net.Dialer.
func WithHTTPExpectContinueTimeout ¶
func WithHTTPExpectContinueTimeout(d time.Duration) HTTPClientOption
WithHTTPExpectContinueTimeout specifies the `ExpectContinueTimeout` to http client.
func WithHTTPIdleConnTimeout ¶
func WithHTTPIdleConnTimeout(d time.Duration) HTTPClientOption
WithHTTPIdleConnTimeout specifies the `IdleConnTimeout` to http client.
func WithHTTPMaxConnsPerHost ¶
func WithHTTPMaxConnsPerHost(n int) HTTPClientOption
WithHTTPMaxConnsPerHost specifies the `MaxConnsPerHost` to http client.
func WithHTTPMaxIdleConns ¶
func WithHTTPMaxIdleConns(n int) HTTPClientOption
WithHTTPMaxIdleConns specifies the `MaxIdleConns` to http client.
func WithHTTPMaxIdleConnsPerHost ¶
func WithHTTPMaxIdleConnsPerHost(n int) HTTPClientOption
WithHTTPMaxIdleConnsPerHost specifies the `MaxIdleConnsPerHost` to http client.
func WithHTTPTLSConfig ¶
func WithHTTPTLSConfig(c *tls.Config) HTTPClientOption
WithHTTPTLSConfig specifies the `TLSClientConfig` to http client.
func WithHTTPTLSHandshakeTimeout ¶
func WithHTTPTLSHandshakeTimeout(d time.Duration) HTTPClientOption
WithHTTPTLSHandshakeTimeout specifies the `TLSHandshakeTimeout` to http client.
type HTTPRequestOption ¶
type HTTPRequestOption interface {
// contains filtered or unexported methods
}
HTTPRequestOption configures how we set up the http request
func WithRequestClose ¶
func WithRequestClose(b bool) HTTPRequestOption
WithRequestClose specifies close the connection after replying to this request (for servers) or after sending this request and reading its response (for clients).
func WithRequestCookies ¶
func WithRequestCookies(cookies ...*http.Cookie) HTTPRequestOption
WithRequestCookies specifies the cookies to http request.
func WithRequestHeader ¶
func WithRequestHeader(key, value string) HTTPRequestOption
WithRequestHeader specifies the headers to http request.
func WithRequestTimeout ¶
func WithRequestTimeout(d time.Duration) HTTPRequestOption
WithRequestTimeout specifies the timeout to http request.