fhttp/http_client.go
changed.
Other files ignored by Codecov
fhttp/http_test.go
has changed.
306 | 306 | url string |
|
307 | 307 | path string // original path of the request's url |
|
308 | 308 | rawQuery string // original query params |
|
309 | + | body string // original body of the request |
|
309 | 310 | req *http.Request |
|
310 | 311 | client *http.Client |
|
311 | 312 | transport *http.Transport |
|
312 | 313 | pathContainsUUID bool // if url contains the "{uuid}" pattern (lowercase) |
|
313 | 314 | rawQueryContainsUUID bool // if any query params contains the "{uuid}" pattern (lowercase) |
|
315 | + | bodyContainsUUID bool // if body contains the "{uuid}" pattern (lowercase) |
|
314 | 316 | } |
|
315 | 317 | ||
316 | 318 | // Close cleans up any resources used by NewStdClient. |
355 | 357 | ||
356 | 358 | c.req.URL.RawQuery = rawQuery |
|
357 | 359 | } |
|
360 | + | if c.bodyContainsUUID { |
|
361 | + | body := c.body |
|
362 | + | for strings.Contains(body, uuidToken) { |
|
363 | + | body = strings.Replace(body, uuidToken, generateUUID(), 1) |
|
364 | + | } |
|
365 | + | bodyBytes := []byte(body) |
|
366 | + | c.req.ContentLength = int64(len(bodyBytes)) |
|
367 | + | c.req.Body = ioutil.NopCloser(bytes.NewReader(bodyBytes)) |
|
368 | + | } |
|
358 | 369 | resp, err := c.client.Do(c.req) |
|
359 | 370 | if err != nil { |
|
360 | 371 | log.Errf("Unable to send %s request for %s : %v", c.req.Method, c.url, err) |
442 | 453 | pathContainsUUID: strings.Contains(req.URL.Path, uuidToken), |
|
443 | 454 | rawQuery: req.URL.RawQuery, |
|
444 | 455 | rawQueryContainsUUID: strings.Contains(req.URL.RawQuery, uuidToken), |
|
456 | + | body: o.PayloadString(), |
|
457 | + | bodyContainsUUID: strings.Contains(o.PayloadString(), uuidToken), |
|
445 | 458 | req: req, |
|
446 | 459 | client: &http.Client{ |
|
447 | 460 | Timeout: o.HTTPReqTimeOut, |
532 | 545 | uuidStrings = append(uuidStrings, uuidString) |
|
533 | 546 | urlString = strings.Replace(urlString, uuidToken, uuidString, 1) |
|
534 | 547 | } |
|
548 | + | payload := o.PayloadString() |
|
549 | + | for strings.Contains(payload, uuidToken) { |
|
550 | + | uuidString := generateUUID() |
|
551 | + | uuidStrings = append(uuidStrings, uuidString) |
|
552 | + | payload = strings.Replace(payload, uuidToken, uuidString, 1) |
|
553 | + | } |
|
554 | + | o.Payload = []byte(payload) |
|
535 | 555 | ||
536 | 556 | // Parse the url, extract components. |
|
537 | 557 | url, err := url.Parse(urlString) |
Files | Coverage |
---|---|
dflag | 82.2% |
fgrpc | 87.9% |
fhttp | 85.4% |
fnet/network.go | 86.9% |
log/logger.go | 86.7% |
periodic/periodic.go | 96.9% |
stats/stats.go | 96.5% |
tcprunner/tcprunner.go | 70.2% |
Project Totals (25 files) | 86.7% |