http

package
v0.3.20 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPSchemeStr  = "http"
	HTTPSSchemeStr = "https"

	MethodGet  = http.MethodGet
	MethodPost = http.MethodPost

	DefaultContentTypeKey   = "Content-Type"
	DefaultContentTypeValue = "application/json"

	StatusOK                  = http.StatusOK
	StatusInternalServerError = http.StatusInternalServerError

	DefaultMaxWaitTime   = 60 // seconds
	DefaultMaxRetryCount = 3
	DefaultDelayTime     = 10 // milliseconds

	DefaultUnlimitedWaitTime   = -1 // seconds
	DefaultUnlimitedRetryCount = -1
)

Variables

View Source
var (
	DefaultTransport = &http.Transport{
		Proxy:                 http.ProxyFromEnvironment,
		DialContext:           (&net.Dialer{Timeout: defaultDialTimeout, KeepAlive: defaultKeepAlive}).DialContext,
		TLSHandshakeTimeout:   defaultTLSHandshakeTimeout,
		TLSClientConfig:       &tls.Config{},
		ForceAttemptHTTP2:     true,
		MaxIdleConns:          defaultMaxIdleConns,
		IdleConnTimeout:       defaultIdleConnTimeout,
		ExpectContinueTimeout: defaultExpectContinueTimeout,
		MaxIdleConnsPerHost:   defaultMaxIdleConnsPerHost,
	}
)

Functions

func PrepareURL

func PrepareURL(url string) string

Types

type Client

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

func NewClient

func NewClient(client *http.Client, maxWaitTime, maxRetryCount, delayTime int) (*Client, error)

func NewClientWithDefault

func NewClientWithDefault() (*Client, error)

func NewClientWithRetry

func NewClientWithRetry() (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) GetClient

func (c *Client) GetClient() *http.Client

func (*Client) GetWithBasicAuth

func (c *Client) GetWithBasicAuth(url string, body []byte, user, pass string) ([]byte, error)

func (*Client) Post

func (c *Client) Post(url string, body []byte) (*http.Response, error)

func (*Client) PostDAS

func (c *Client) PostDAS(url string, body []byte) ([]byte, error)

func (*Client) PostWithBasicAuth

func (c *Client) PostWithBasicAuth(url string, body []byte, user, pass string) ([]byte, error)

func (*Client) PrepareURL added in v0.3.18

func (c *Client) PrepareURL(scheme, addr, path string, params map[string]string) string

PrepareURL prepares the url

func (*Client) SendRequestWithBasicAuth

func (c *Client) SendRequestWithBasicAuth(method, url string, body []byte, user, pass string) ([]byte, error)

func (*Client) SendRequestWithHeaderAndBody added in v0.3.18

func (c *Client) SendRequestWithHeaderAndBody(method, url string, header map[string]string, body []byte) ([]byte, error)

func (*Client) SetMaxIdleConns

func (c *Client) SetMaxIdleConns(maxIdleConns int)

func (*Client) SetMaxIdleConnsPerHost

func (c *Client) SetMaxIdleConnsPerHost(maxIdleConnsPerHost int)

func (*Client) SetRetryOption

func (c *Client) SetRetryOption(maxWaitTime, maxRetryCount, delay int)

func (*Client) SetTLSInsecureSkipVerify added in v0.3.18

func (c *Client) SetTLSInsecureSkipVerify(skip bool) error

SetTLSInsecureSkipVerify sets TLS insecure skip verify

type Request added in v0.3.20

type Request = http.Request

type Response added in v0.3.20

type Response = http.Response

Jump to

Keyboard shortcuts

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