Skip to content

Commit

Permalink
fix adding header for thrift inbound request in case of too large one
Browse files Browse the repository at this point in the history
  • Loading branch information
yangjing committed Nov 2, 2020
1 parent 425735f commit fe1c217
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions replayer-agent/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ require (
github.com/spf13/viper v1.6.3
github.com/ugorji/go v1.1.7 // indirect
go.uber.org/zap v1.15.0
golang.org/x/sys v0.0.0-20190412213103-97732733099d
gopkg.in/go-playground/validator.v8 v8.18.2 // indirect
)
8 changes: 5 additions & 3 deletions replayer-agent/logic/worker/replayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ func (r *Replayer) ReplaySessionDoreplay(ctx context.Context, session *replaying
timeHeader := fmt.Sprintf("\r\nSharingan-Replayer-Time: %d", session.CallFromInbound.OccurredAt)
s := bytes.Split(request, []byte("\r\n"))
if strings.Contains(string(s[0]), " HTTP/") {
// http: add at the second linethe first line cannot be changed for 400 Bad Request
// http: add header at the second line of http inbound. the first line cannot be changed for 400 Bad Request
s[0] = append(s[0], []byte(traceHeader+timeHeader)...)
request = bytes.Join(s, []byte("\r\n"))
} else {
// thrift: add at the end for the thrift inbound
request = append(request, []byte(traceHeader+timeHeader)...)
// thrift: add header at the first line of thrift inbound, for thrift request may be too large
traceHeader = fmt.Sprintf("Sharingan-Replayer-Traceid: %s\r\n", traceID)
timeHeader = fmt.Sprintf("Sharingan-Replayer-Time: %d\r\n", session.CallFromInbound.OccurredAt)
request = append([]byte(traceHeader+timeHeader), request...)
}
}

Expand Down

0 comments on commit fe1c217

Please sign in to comment.