httpz

package
v15.0.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConnectionHeader         = "Connection" // https://datatracker.ietf.org/doc/html/rfc7230#section-6.1
	ProxyConnectionHeader    = "Proxy-Connection"
	KeepAliveHeader          = "Keep-Alive"
	HostHeader               = "Host"
	ProxyAuthenticateHeader  = "Proxy-Authenticate"
	ProxyAuthorizationHeader = "Proxy-Authorization"
	TeHeader                 = "Te"      // canonicalized version of "TE"
	TrailerHeader            = "Trailer" // not Trailers as per rfc2616; See errata https://www.rfc-editor.org/errata_search.php?eid=4522
	TransferEncodingHeader   = "Transfer-Encoding"
	UpgradeHeader            = "Upgrade"
	UserAgentHeader          = "User-Agent"
	AuthorizationHeader      = "Authorization"
	ContentTypeHeader        = "Content-Type"
	AcceptHeader             = "Accept"
	ServerHeader             = "Server"
	ViaHeader                = "Via" // https://datatracker.ietf.org/doc/html/rfc7230#section-5.7.1
)

These headers must be in their canonical form. Only add headers used in production code, don't bother with tests.

Variables

This section is empty.

Functions

func RemoveConnectionHeaders

func RemoveConnectionHeaders(h http.Header)

RemoveConnectionHeaders removes hop-by-hop headers listed in the "Connection" header of h. See https://datatracker.ietf.org/doc/html/rfc7230#section-6.1

func RunServer

func RunServer(ctx context.Context, srv *http.Server, listener net.Listener, shutdownTimeout time.Duration) error

Types

type Limiter

type Limiter interface {
	// Wait blocks until limiter permits an event to happen.
	// It returns an error if the Context is
	// canceled, or the expected wait time exceeds the Context's Deadline.
	Wait(context.Context) error
}

Limiter defines the interface to perform client-side request rate limiting. You can use golang.org/x/time/rate.Limiter as an implementation of this interface.

type RateLimitingRoundTripper

type RateLimitingRoundTripper struct {
	Delegate http.RoundTripper
	Limiter  Limiter
}

func (*RateLimitingRoundTripper) RoundTrip

func (r *RateLimitingRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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