goreplay icon indicating copy to clipboard operation
goreplay copied to clipboard

Rewrite multi header can't work?

Open HeartIsBeat opened this issue 3 years ago • 1 comments

I use gor1.3.3 wget https://github.com/buger/goreplay/releases/download/1.3.3/gor_1.3.3_x64.tar.gz

gor record traffic like this: image or like this: image

I want to rewrite header: authorization and authorization-virtual. using --http-rewrite-header 'authorization: XDS [a-zA-Z0-9.-_/+/-]+,xxx' --http-rewrite-header 'authorization-virtual: VDS [a-zA-Z0-9.-_/+/-]+,VDS xxx'

authorization can be rewrited. But authorization-virtual can't be rewrited

HeartIsBeat avatar Aug 11 '22 08:08 HeartIsBeat

There is a bug here.

    if len(m.config.HeaderRewrite) > 0 {
            for _, f := range m.config.HeaderRewrite {
                    value := proto.Header(payload, f.header)
                    if len(value) == 0 {
                            break    <<<<<<<<<< if header "authorization" is not found, it will not try the left "authorization-virtual"
                    }

                    if f.src.Match(value) {
                            newValue := f.src.ReplaceAll(value, f.target)
                            payload = proto.SetHeader(payload, f.header, newValue)
                    }
            }
    }

I will submit a fix for this.

zoulinz avatar Aug 22 '22 11:08 zoulinz