header

package
v2.0.0-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2015 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy.

Index

Constants

This section is empty.

Variables

View Source
var HopByHopHeaders = []string{
	"Connection",
	"Keep-Alive",
	"Proxy-Authenticate",
	"Proxy-Authorization",
	"Te",
	"Trailer",
	"Transfer-Encoding",
	"Upgrade",
}

Hop-by-hop headers as defined by RFC2616.

http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-7.1.3.1

Functions

func NewBadFramingModifier

func NewBadFramingModifier() martian.RequestModifier

NewBadFramingModifier makes a best effort to fix inconsistencies in the request such as multiple Content-Lengths or the lack of Content-Length and improper Transfer-Encoding. If it is unable to determine a proper resolution it returns an error.

http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-14#section-3.3

func NewBlacklistModifier

func NewBlacklistModifier(names ...string) martian.RequestResponseModifier

NewBlacklistModifier returns a modifier that will delete any header that matches a name contained in the names parameter.

func NewForwardedModifier

func NewForwardedModifier() martian.RequestModifier

NewForwardedModifier sets the X-Forwarded-For and X-Forwarded-Proto headers.

If X-Forwarded-For is already present, the client IP is appended to the existing value.

TODO: Support "Forwarded" header. see: http://tools.ietf.org/html/rfc7239

func NewHopByHopModifier

func NewHopByHopModifier() martian.RequestResponseModifier

NewHopByHopModifier removes Hop-By-Hop headers from requests and responses.

func NewModifier

func NewModifier(name, value string) martian.RequestResponseModifier

NewModifier returns a modifier that will set the header at name with the given value for both requests and responses. If the header name already exists all values will be overwritten.

func NewVerifier

func NewVerifier(name, value string) verify.RequestResponseVerifier

NewVerifier creates a new header verifier for the given name and value.

func NewViaModifier

func NewViaModifier(requestedBy string) martian.RequestResponseModifier

NewViaModifier returns a new Via modifier.

Types

type Filter

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

Filter filters requests and responses based on header name and value.

func NewFilter

func NewFilter(name, value string) *Filter

NewFilter builds a new header filter.

func (*Filter) ModifyRequest

func (f *Filter) ModifyRequest(req *http.Request) error

ModifyRequest runs reqmod iff req has a header with name matching value.

func (*Filter) ModifyResponse

func (f *Filter) ModifyResponse(res *http.Response) error

ModifyResponse runs resmod iff res has a header with name matching value.

func (*Filter) ResetRequestVerifications

func (f *Filter) ResetRequestVerifications()

ResetRequestVerifications resets the state of the contained request verifiers.

func (*Filter) ResetResponseVerifications

func (f *Filter) ResetResponseVerifications()

ResetResponseVerifications resets the state of the contained request verifiers.

func (*Filter) SetRequestModifier

func (f *Filter) SetRequestModifier(reqmod martian.RequestModifier)

SetRequestModifier sets the request modifier of filter.

func (*Filter) SetResponseModifier

func (f *Filter) SetResponseModifier(resmod martian.ResponseModifier)

SetResponseModifier sets the response modifier of filter.

func (*Filter) VerifyRequests

func (f *Filter) VerifyRequests() error

VerifyRequests returns an error containing all the verification errors returned by request verifiers.

func (*Filter) VerifyResponses

func (f *Filter) VerifyResponses() error

VerifyResponses returns an error containing all the verification errors returned by response verifiers.

Jump to

Keyboard shortcuts

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