Generic request functions
(t testing.TB, req *http.Request, requestHeaders []string)
| 485 | // Generic request functions |
| 486 | |
| 487 | func applyHeaders(t testing.TB, req *http.Request, requestHeaders []string) { |
| 488 | requestContentType := "" |
| 489 | for _, requestHeader := range requestHeaders { |
| 490 | arr := strings.SplitAfterN(requestHeader, ":", 2) |
| 491 | k := strings.TrimRight(arr[0], ":") |
| 492 | v := strings.TrimSpace(arr[1]) |
| 493 | if k == "Content-Type" { |
| 494 | requestContentType = v |
| 495 | } |
| 496 | t.Logf("Request header: %s => %s", k, v) |
| 497 | req.Header.Set(k, v) |
| 498 | } |
| 499 | |
| 500 | if requestContentType == "" { |
| 501 | t.Logf("Content-Type header not provided") |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | // AssertResponseCode will execute the request and verify the status code, returns a response for additional assertions |
| 506 | func (tc *Tester) AssertResponseCode(req *http.Request, expectedStatusCode int) *http.Response { |
no test coverage detected