Documentation ¶
Overview ¶
Package header provides utilities for modifying, filtering, and verifying headers in martian.Proxy.
Index ¶
- func NewAppendModifier(name, value string) martian.RequestResponseModifier
- func NewBadFramingModifier() martian.RequestModifier
- func NewBlacklistModifier(names ...string) martian.RequestResponseModifier
- func NewCopyModifier(from, to 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
- type Filter
- type Matcher
- type ValueRegexFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAppendModifier ¶
func NewAppendModifier(name, value string) martian.RequestResponseModifier
NewAppendModifier returns an appendModifier that will append a header with with the given name and value for both requests and responses. Existing headers with the same name will be left in place.
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 NewCopyModifier ¶
func NewCopyModifier(from, to string) martian.RequestResponseModifier
NewCopyModifier returns a modifier that will copy the header in from to the header in to.
func NewForwardedModifier ¶
func NewForwardedModifier() martian.RequestModifier
NewForwardedModifier sets the X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Url headers.
If X-Forwarded-For is already present, the client IP is appended to the existing value. X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Url are preserved if already present.
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.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is a conditonal evalutor of request or response headers to be used in structs that take conditions.
func NewMatcher ¶
NewMatcher builds a new header matcher.
func (*Matcher) MatchRequest ¶
MatchRequest evaluates a request and returns whether or not the request contains a header that matches the provided name and value.
type ValueRegexFilter ¶
type ValueRegexFilter struct {
// contains filtered or unexported fields
}
ValueRegexFilter executes resmod and reqmod when the header value matches regex.
func NewValueRegexFilter ¶
func NewValueRegexFilter(regex *regexp.Regexp, header string) *ValueRegexFilter
NewValueRegexFilter builds a new header value regex filter.
func (*ValueRegexFilter) ModifyRequest ¶
func (f *ValueRegexFilter) ModifyRequest(req *http.Request) error
ModifyRequest runs reqmod iff the value of header matches regex.
func (*ValueRegexFilter) ModifyResponse ¶
func (f *ValueRegexFilter) ModifyResponse(res *http.Response) error
ModifyResponse runs resmod iff the value of request header matches regex.
func (*ValueRegexFilter) SetRequestModifier ¶
func (f *ValueRegexFilter) SetRequestModifier(reqmod martian.RequestModifier)
SetRequestModifier sets the request modifier of HeaderValueRegexFilter.
func (*ValueRegexFilter) SetResponseModifier ¶
func (f *ValueRegexFilter) SetResponseModifier(resmod martian.ResponseModifier)
SetResponseModifier sets the response modifier of HeaderValueRegexFilter.