Description
Bug or incorrect usage?
Linux, GoReplay 1.1.0
I am trying two scenarios:
- rewrite the value of a header (http-rewrite-header). The header to be rewritten is HeaderA (there is no HeaderA in the incoming reqest).
- insert a new header (http-set-header). The header to be inserted is 'HeaderA: whatever' (there is no HeaderA in the incoming reqest).
For the both scenarios there is a header "HeaderASomething: AAA" in the incoming request. Note the similarity between the names of HeaderASomething and HeaderA.
The outcome in the both scenarios is HeaderASomething from the incoming request becomes an empty header with a mangled name in the forwarded request.
- Rewrite the value of a header (option passed is: --http-rewrite-header 'HeaderA:(.),BBB'):
the output of goreplay -h states:
Rewrite the request header based on a mapping:
gor --input-raw :8080 --output-http staging.com --http-rewrite-header Host: (.).example.com,$1.beta.example.com
My expectation here is either a full match or no match for the header name. Or some instructions of how to steer the
matching of the header name (regex?).
The actual behaviour is "HeaderASomething: AAA" from the incoming request becomes an empty header "HeaderASBBB".
Is HeaderASBBB = HeaderAS + BBB?
Please see the example below
on a host testhost goreplay is started:
goreplay -debug -verbose -input-raw :80 -output-http http://someserver/:80/ --http-disallow-url health --http-rewrite-header 'HeaderA:(.*),BBB'
a request is made to testhost:80
curl -X GET "http://testhost/some/path" -H "accept: application/json" -H "HeaderASomething: AAA"
output of goreplay (the incoming request)
[DEBUG][PID 369][Jul 13 14:58:19.149142905][elapsed 84.718µs] [EMITTER] input: 1 34a6276f26b6845b9d50f277456946be5742f0ee 1626188299148988883
GET /some/path HTTP/1.1
Host: testhost
User-Agent: curl/7.64.1
accept: application/json
HeaderASomething: AAA
tcpdump running on testhost (tcpdump -vvAs0 -i eth0 dst host someserver and dst port 80) outputs
the forwarded request with the mangled HeaderASomething
14:59:51.809125 IP (tos 0x0, ttl 64, id 49070, offset 0, flags [DF], proto TCP (6), length 193)
testhost.39894 > someserver.80: Flags [P.], cksum 0x4181 (incorrect -> 0x6b2b), seq 0:153, ack 1, win 55, length 153: HTTP, length: 153
GET /some/path HTTP/1.1
Host: someserverIP
User-Agent: curl/7.64.1
accept: application/json
HeaderASBBB
- Insert a new header (option passed is: -http-set-header 'HeaderA: whatever')
the output of goreplay -h states:
Inject additional headers to http request:
gor --input-raw :8080 --output-http staging.com --http-set-header 'User-Agent: Gor'
My expectation here is a new header is inserted. If there is a full match for the existing header name then
probably the value is replaced for the matched header.
The actual behavior is "HeaderASomething: AAA" from the incoming request becomes empty header "HeaderASwhatever".
Is HeaderASwhatever = HeaderAS + whatever?
Please see the example below:
on a host testhost goreplay is started:
goreplay -debug -verbose -input-raw :80 -output-http http://someserver/:80/ -http-disallow-url health -http-set-header 'HeaderA: whatever'
a request is made to testhost:80
curl -X GET "http://testhost/some/path" -H "accept: application/json" -H "HeaderASomething: AAA"
output of goreplay (the incoming request)
[DEBUG][PID 433][Jul 13 15:06:12.656579199][elapsed 152.294µs] [EMITTER] input: 1 38fd003766417552eafcb9d1182ca94ca29e84c4 1626188772656372710
GET /some/path HTTP/1.1
Host: testhost
User-Agent: curl/7.64.1
accept: application/json
HeaderASomething: AAA
tcpdump running on testhost (tcpdump -vvAs0 -i eth0 dst host someserver and dst port 80) outputs
the forwarded request with the mangled HeaderASomething header
15:06:12.740177 IP (tos 0x0, ttl 64, id 62871, offset 0, flags [DF], proto TCP (6), length 198)
testhost.50774 > someserver.80: Flags [P.], cksum 0x4186 (incorrect -> 0xc812), seq 0:158, ack 1, win 55, length 158: HTTP, length: 158
GET /some/path HTTP/1.1
Host: someserverIP
User-Agent: curl/7.64.1
accept: application/json
HeaderASwhatever