http

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Registry prometheus.Registerer = registry
	Gatherer prometheus.Gatherer   = registry
)

Functions

func InRange

func InRange(code, a, b int) bool

InRange ...

func ParseHeaders

func ParseHeaders(headers []string) http.Header

ParseHeaders ...

Types

type Client

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

Client ...

func New

func New(conf Config) (*Client, error)

New ...

func (*Client) Do

func (c *Client) Do(method string, rel *url.URL, headers http.Header, body io.Reader) (*Response, error)

Do ...

type Config

type Config struct {
	URL string

	// Timeout specifies a time limit for requests made by this
	// Client. The timeout includes connection time, any
	// redirects, and reading the response body. The timer remains
	// running after Get, Head, Post, or Do return and will
	// interrupt reading of the Response.Body.
	// A Timeout of zero means no timeout.
	Timeout time.Duration

	// IdleConnTimeout is the maximum amount of time an idle
	// (keep-alive) connection will remain idle before closing
	// itself.
	// Zero means no limit.
	IdleConnTimeout time.Duration

	// InsecureSkipVerify controls whether a client verifies the
	// server's certificate chain and host name.
	// If InsecureSkipVerify is true, TLS accepts any certificate
	// presented by the server and any host name in that certificate.
	InsecureSkipVerify bool

	// MaxConnsPerHost optionally limits the total number of
	// connections per host, including connections in the dialing,
	// active, and idle states. On limit violation, dials will block.
	// Zero means no limit.
	MaxConnsPerHost int

	// MaxIdleConns controls the maximum number of idle (keep-alive)
	// connections across all hosts. Zero means no limit.
	MaxIdleConns int

	// MaxIdleConnsPerHost, if non-zero, controls the maximum idle
	// (keep-alive) connections to keep per-host. If zero,
	// DefaultMaxIdleConnsPerHost is used.
	MaxIdleConnsPerHost int

	Headers http.Header
}

Config ...

type Request

type Request struct {
	Method   string
	Header   http.Header
	URL      *url.URL
	Body     io.Reader
	Response *Response
}

Request ...

func NewRequest

func NewRequest(method, rawurl string, header http.Header, body io.Reader, fields map[string]string) (*Request, error)

NewRequest ...

type Response

type Response struct {
	Status           string // e.g. "200 OK"
	StatusCode       int    // e.g. 200
	Proto            string // e.g. "HTTP/1.0"
	ProtoMajor       int    // e.g. 1
	ProtoMinor       int    // e.g. 0
	Header           http.Header
	Body             []byte
	ContentLength    int64
	TransferEncoding []string
	Uncompressed     bool
	Trailer          http.Header
	Duration         time.Duration
	Request          *http.Request
}

Response ...

Jump to

Keyboard shortcuts

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