Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed reset process for request Body for temporary support #342

Closed
wants to merge 12 commits into from
15 changes: 4 additions & 11 deletions http.go
Expand Up @@ -238,7 +238,8 @@ func (rnr *httpRunner) Run(ctx context.Context, r *httpRequest) error {
if err != nil {
return err
}
req, err = http.NewRequestWithContext(ctx, r.method, u.String(), reqBody)
bw := new(bytes.Buffer)
req, err = http.NewRequestWithContext(ctx, r.method, u.String(), io.TeeReader(reqBody, bw))
if err != nil {
return err
}
Expand All @@ -252,16 +253,8 @@ func (rnr *httpRunner) Run(ctx context.Context, r *httpRequest) error {
if err := rnr.validator.ValidateRequest(ctx, req); err != nil {
return err
}
// reset Request.Body
reqBody, err := r.encodeBody()
if err != nil {
return err
}
rc, ok := reqBody.(io.ReadCloser)
if !ok && reqBody != nil {
rc = io.NopCloser(reqBody)
}
req.Body = rc
// reset ContentLength
req.ContentLength = int64(bw.Len())

r.setContentTypeHeader(req)
for k, v := range r.headers {
Expand Down