Documentation ¶
Overview ¶
Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy.
Index ¶
- Variables
- func NewBadFramingModifier() martian.RequestModifier
- func NewBlacklistModifier(names ...string) martian.RequestResponseModifier
- func NewForwardedModifier() martian.RequestModifier
- func NewHopByHopModifier() martian.RequestResponseModifier
- func NewModifier(name, value string) martian.RequestResponseModifier
- func NewVerifier(name, value string) verify.RequestResponseVerifier
- func NewViaModifier(requestedBy string) martian.RequestResponseModifier
- type Filter
- func (f *Filter) ModifyRequest(req *http.Request) error
- func (f *Filter) ModifyResponse(res *http.Response) error
- func (f *Filter) ResetRequestVerifications()
- func (f *Filter) ResetResponseVerifications()
- func (f *Filter) SetRequestModifier(reqmod martian.RequestModifier)
- func (f *Filter) SetResponseModifier(resmod martian.ResponseModifier)
- func (f *Filter) VerifyRequests() error
- func (f *Filter) VerifyResponses() error
Constants ¶
This section is empty.
Variables ¶
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 (*Filter) ModifyRequest ¶
ModifyRequest runs reqmod iff req has a header with name matching value.
func (*Filter) ModifyResponse ¶
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 ¶
VerifyRequests returns an error containing all the verification errors returned by request verifiers.
func (*Filter) VerifyResponses ¶
VerifyResponses returns an error containing all the verification errors returned by response verifiers.