mirror of
https://github.com/buger/goreplay.git
synced 2024-04-21 12:32:02 +00:00
add --http-disallow-header option
This commit is contained in:
+13
-1
@@ -2,8 +2,9 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/buger/gor/proto"
|
||||
"hash/fnv"
|
||||
|
||||
"github.com/buger/gor/proto"
|
||||
)
|
||||
|
||||
type HTTPModifier struct {
|
||||
@@ -16,6 +17,7 @@ func NewHTTPModifier(config *HTTPModifierConfig) *HTTPModifier {
|
||||
len(config.urlNegativeRegexp) == 0 &&
|
||||
len(config.urlRewrite) == 0 &&
|
||||
len(config.headerFilters) == 0 &&
|
||||
len(config.headerNegativeFilters) == 0 &&
|
||||
len(config.headerHashFilters) == 0 &&
|
||||
len(config.paramHashFilters) == 0 &&
|
||||
len(config.params) == 0 &&
|
||||
@@ -94,6 +96,16 @@ func (m *HTTPModifier) Rewrite(payload []byte) (response []byte) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(m.config.headerNegativeFilters) > 0 {
|
||||
for _, f := range m.config.headerNegativeFilters {
|
||||
value, s, _, _ := proto.Header(payload, f.name)
|
||||
|
||||
if s != -1 && f.regexp.Match(value) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(m.config.headerHashFilters) > 0 {
|
||||
for _, f := range m.config.headerHashFilters {
|
||||
value, s, _, _ := proto.Header(payload, f.name)
|
||||
|
||||
Reference in New Issue
Block a user