Skip to content

Commit

Permalink
Fix json bug by reusing pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
na-- committed Dec 4, 2019
1 parent 6a552ad commit 45fef98
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions js/modules/k6/http/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,10 @@ func (h *HTTP) parseRequest(

func (h *HTTP) prepareBatchArray(
ctx context.Context, requests []interface{},
) ([]httpext.BatchParsedHTTPRequest, []Response, error) {
) ([]httpext.BatchParsedHTTPRequest, []*Response, error) {
reqCount := len(requests)
batchReqs := make([]httpext.BatchParsedHTTPRequest, reqCount)
results := make([]Response, reqCount)
results := make([]*Response, reqCount)

for key, req := range requests {
parsedReq, err := h.parseBatchRequest(ctx, key, req)
Expand All @@ -373,18 +373,18 @@ func (h *HTTP) prepareBatchArray(
ParsedHTTPRequest: parsedReq,
Response: response,
}
results[key] = Response{response}
results[key] = &Response{response}
}

return batchReqs, results, nil
}

func (h *HTTP) prepareBatchObject(
ctx context.Context, requests map[string]interface{},
) ([]httpext.BatchParsedHTTPRequest, map[string]Response, error) {
) ([]httpext.BatchParsedHTTPRequest, map[string]*Response, error) {
reqCount := len(requests)
batchReqs := make([]httpext.BatchParsedHTTPRequest, reqCount)
results := make(map[string]Response, reqCount)
results := make(map[string]*Response, reqCount)

i := 0
for key, req := range requests {
Expand All @@ -397,7 +397,7 @@ func (h *HTTP) prepareBatchObject(
ParsedHTTPRequest: parsedReq,
Response: response,
}
results[key] = Response{response}
results[key] = &Response{response}
i++
}

Expand Down

0 comments on commit 45fef98

Please sign in to comment.