hc

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPStatusText added in v0.0.16

func HTTPStatusText(status int) string

HTTPStatusText lookup status code for text

func MakeCall added in v0.0.16

func MakeCall(method, URI string, msg io.Reader, header map[string]string, auth *Auth, settings *HTTPClientSettings) (map[string]interface{}, int, error)

MakeCall to http client

func Reachable

func Reachable(host, name string, timeout int, disableVerifyCert bool) (bool, error)

Reachable is the url reachable

Types

type Auth

type Auth struct {
	Username []byte
	Password []byte
}

type Client

type Client struct {
	DialTimeout           time.Duration
	DialKeepAliveTimeout  time.Duration
	MaxIdleConnections    int
	IdleConnTimeout       time.Duration
	TLSHandshakeTimeout   time.Duration
	ResponseHeaderTimeout time.Duration
	//ExpectContinueTimeout    time.Duration	// will disable HTTP2 if used
	HTTPClientRequestTimeout  time.Duration
	CheckRedirectUserLastResp bool
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) *Client

func (*Client) Fetch

func (c *Client) Fetch(method, url string, auth *Auth, header map[string]string, body io.Reader) (*http.Response, error)

func (*Client) FetchTLS

func (c *Client) FetchTLS(method, url string, auth Auth, header map[string]string, body io.Reader, serverCAPath string, cert ClientCert) (*http.Response, error)

func (*Client) FetchTLSWithContext added in v0.0.10

func (c *Client) FetchTLSWithContext(ctx context.Context, method, url string, auth Auth, header map[string]string, body io.Reader, serverCAPath string, cert ClientCert) (*http.Response, error)

func (*Client) FetchWithContext added in v0.0.10

func (c *Client) FetchWithContext(ctx context.Context, method, url string, auth *Auth, header map[string]string, body io.Reader) (*http.Response, error)

func (*Client) ProxiedClient

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

ProxiedClient Proxy should be set with os.Setenv

type ClientCert

type ClientCert struct {
	Certificate string
	Key         string
}

type ClientOption

type ClientOption func(h *Client)

func CheckRedirectUserLastResp added in v0.0.18

func CheckRedirectUserLastResp(b bool) ClientOption

func DialKeepAliveTimeout

func DialKeepAliveTimeout(i int) ClientOption

func DialTimeout

func DialTimeout(i int) ClientOption

func DisableVerifyClientCert

func DisableVerifyClientCert(b bool) ClientOption

func HTTPClientRequestTimeout added in v0.0.21

func HTTPClientRequestTimeout(i int) ClientOption

func HTTPClientResponseHeaderTimeout added in v0.0.21

func HTTPClientResponseHeaderTimeout(i int) ClientOption

func IdleConnectionTimeout

func IdleConnectionTimeout(i int) ClientOption

func MaxIdleConnections

func MaxIdleConnections(i int) ClientOption

func TLSHandshakeTimeout

func TLSHandshakeTimeout(i int) ClientOption

type HTTPClient added in v0.0.16

type HTTPClient struct {
	Method                  string
	URL                     string
	Header                  map[string]string
	ReturnHead              bool
	ReturnKeys              []string
	ReturnCert              bool
	ReUseClient             bool
	RedirectUseLastResponse bool
	Auth                    *Auth
	RequestTimeout          int
	ResponseHeaderTimeout   int
	DialTimeout             int
	DialKeepAliveTimeout    int
	MaxIdleConnections      int
	IdleConnectionTimeout   int
	TLSHandshakeTimeout     int
	DisableVerifyClientCert bool
	CatchAllErrStatus       int
}

HTTPClient data store

func NewHTTPClient added in v0.0.16

func NewHTTPClient(method, url string, header map[string]string, auth *Auth, settings *HTTPClientSettings) *HTTPClient

NewHTTPClient initialize HTTPClient

func (*HTTPClient) Process added in v0.0.16

func (h *HTTPClient) Process(data io.Reader) (map[string]interface{}, int, error)

Process method on HTTPCall object, pass in reader

type HTTPClientSettings added in v0.0.16

type HTTPClientSettings struct {
	ReturnHeaders           bool
	DisableVerifyClientCert bool
	RequestTimeout          int
	ResponseHeaderTimeout   int
	ReturnCert              bool
	ReUseClient             bool
	RedirectUseLastResponse bool
	DialTimeout             int
	DialKeepAliveTimeout    int
	MaxIdleConnections      int
	IdleConnectionTimeout   int
	TLSHandshakeTimeout     int
	CatchAllErrStatus       int
}

func NewClientSettings added in v0.0.16

func NewClientSettings(returnHeaders, disableVerifyClientCert bool, requestTimeout, responseHeaderTimeout int) *HTTPClientSettings

type Info added in v0.0.7

type Info struct {
	Host      string        `json:"host,omitempty"`
	Start     time.Time     `json:"start"`
	End       time.Time     `json:"end,omitempty"`
	Stop      time.Duration `json:"stop"`
	Completed bool          `json:"completed"`
	Error     error         `json:"error,omitempty"`
}

type TestClient

type TestClient struct {
}

func (*TestClient) Client

func (c *TestClient) Client(contype string, hostAr []string, proxy string) *[]netut.Host

Client create an HTTP Client

type TraceInfo added in v0.0.7

type TraceInfo struct {
	Start                time.Time `json:"start"`
	DNS                  Info      `json:"dns"`
	Connect              Info      `json:"connect"`
	TLSHandshake         Info      `json:"tls_handshake"`
	Connection           Info      `json:"connection"`
	GotFirstResponseByte Info      `json:"got_first_response_byte"`
	WroteHeaders         Info      `json:"wrote_headers"`
	WroteRequest         Info      `json:"wrote_request"`
}

func Trace added in v0.0.7

func Trace() (*httptrace.ClientTrace, *TraceInfo)

Jump to

Keyboard shortcuts

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