MCPcopy
hub / github.com/caddyserver/caddy / applyHeaders

Function applyHeaders

caddytest/caddytest.go:487–503  ·  view source on GitHub ↗

Generic request functions

(t testing.TB, req *http.Request, requestHeaders []string)

Source from the content-addressed store, hash-verified

485// Generic request functions
486
487func 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
506func (tc *Tester) AssertResponseCode(req *http.Request, expectedStatusCode int) *http.Response {

Callers 3

AssertPutResponseBodyMethod · 0.85

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected