mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
Add support for restricting certain urls
This commit is contained in:
+9
-10
@@ -5,16 +5,6 @@ import (
|
||||
"hash/fnv"
|
||||
)
|
||||
|
||||
type HTTPModifierConfig struct {
|
||||
urlRegexp HTTPUrlRegexp
|
||||
urlRewrite UrlRewriteMap
|
||||
headerFilters HTTPHeaderFilters
|
||||
headerHashFilters HTTPHeaderHashFilters
|
||||
|
||||
headers HTTPHeaders
|
||||
methods HTTPMethods
|
||||
}
|
||||
|
||||
type HTTPModifier struct {
|
||||
config *HTTPModifierConfig
|
||||
}
|
||||
@@ -47,6 +37,15 @@ func (m *HTTPModifier) Rewrite(payload []byte) (response []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
if m.config.urlNegativeRegexp.regexp != nil {
|
||||
host, _, _, _ := proto.Header(payload, []byte("Host"))
|
||||
fullPath := append(host, proto.Path(payload)...)
|
||||
|
||||
if m.config.urlNegativeRegexp.regexp.Match(fullPath) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if len(m.config.headerFilters) > 0 {
|
||||
for _, f := range m.config.headerFilters {
|
||||
value, s, _, _ := proto.Header(payload, f.name)
|
||||
|
||||
Reference in New Issue
Block a user