transport

package module
v3.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: MIT Imports: 12 Imported by: 0

README

transport

GoDoc

Client for HTTP request

Dependencies
- golang.org/x/text
- golang.org/x/tools
Install
go get github.com/webnice/transport/v3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugFunc

type DebugFunc func(data []byte)

DebugFunc Is an a function for debug request/response data

type DialContextFunc

type DialContextFunc func(ctx context.Context, network, addr string) (net.Conn, error)

DialContextFunc Type of custom dial function for creating unencrypted TCP connections

type DialTLSFunc

type DialTLSFunc func(network, addr string) (net.Conn, error)

DialTLSFunc Type of custom dial function for creating TLS connections for non-proxied HTTPS requests

type ErrorFunc

type ErrorFunc func(err error)

ErrorFunc Is an a client error retrieval function

type Interface

type Interface interface {
	// Method Return interface of request methods
	Method() methods.Interface

	// RequestPoolSize Specifies a number of workers in the query pool
	RequestPoolSize(n uint16) Interface

	// ProxyFunc Specifies a function to return a proxy for a given Request
	ProxyFunc(f ProxyFunc) Interface

	// ProxyConnectHeader Optionally specifies headers to send to proxies during CONNECT requests
	ProxyConnectHeader(v http.Header) Interface

	// DialContextTimeout Is the maximum amount of time a dial will wait for a connect to complete. The default is no timeout
	DialContextTimeout(t time.Duration) Interface

	// DialContextKeepAlive Specifies the keep-alive period for an active network connection. If zero, keep-alives are not enabled
	DialContextKeepAlive(t time.Duration) Interface

	// MaximumIdleConnections Controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit
	MaximumIdleConnections(v uint) Interface

	// MaximumIdleConnectionsPerHost If non-zero, controls the maximum idle (keep-alive) connections to keep per-host
	MaximumIdleConnectionsPerHost(v uint) Interface

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

	// TLSHandshakeTimeout Specifies the maximum amount of time waiting to wait for a TLS handshake. Zero means no timeout
	TLSHandshakeTimeout(t time.Duration) Interface

	// TLSSkipVerify Enables skip verify TLS certificate for all requests
	TLSSkipVerify(v bool) Interface

	// TLSClientConfig Specifies the TLS configuration to use with tls.Client.
	TLSClientConfig(v *tls.Config) Interface

	// DialTLS Specifies an custom dial function for creating TLS connections for non-proxied HTTPS requests
	DialTLS(fn DialTLSFunc) Interface

	// DialContextCustomFunc Specifies an custom dial function for creating unencrypted TCP connections
	DialContextCustomFunc(fn DialContextFunc) Interface

	// DualStack Enables RFC 6555-compliant "Happy Eyeballs" dialing when the network is "tcp" and the host in the address parameter resolves to both IPv4 and IPv6 addresses
	DualStack(v bool) Interface

	// TotalTimeout 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.
	TotalTimeout(t time.Duration) Interface

	// Transport Specifies of adjusted transport object
	Transport(tr *http.Transport) Interface

	// CookieJar Specifies of Cookie Jar interface
	CookieJar(v http.CookieJar) Interface

	// RequestGet Загрузка из sync.Pool объекта request и возврат интерфейса к нему
	// Полученный объект необходимо возвращать в sync.Pool методом RequestPut во избежании утечки памяти
	RequestGet() request.Interface

	// RequestPut Возврат в sync.Pool объекта request
	RequestPut(req request.Interface)

	// Client Returns the current http.Client
	Client() *http.Client

	// Do Executing the query in synchronous mode. Blocking function
	Do(req request.Interface) Interface

	// Done Stopping the worker pool, closing connections
	Done()

	// DebugFunc Set debug func and enable or disable debug mode
	// If fn=not nil - debug mode is enabled. If fn=nil, debug mode is disbled
	DebugFunc(fn DebugFunc) Interface

	// Error Return latest error
	Error() error

	// ErrorFunc Registering the error function on the client side
	ErrorFunc(fn ErrorFunc) Interface
}

Interface is an interface of object

func New

func New() Interface

New Function creates the transport object and return interface

type ProxyFunc

type ProxyFunc func(*http.Request) (*url.URL, error)

ProxyFunc Is an a function to return a proxy for a given Request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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