MCPcopy
hub / github.com/davecheney/httpstat / newRequest

Function newRequest

main.go:395–409  ·  view source on GitHub ↗
(method string, url *url.URL, body string)

Source from the content-addressed store, hash-verified

393}
394
395func newRequest(method string, url *url.URL, body string) *http.Request {
396 req, err := http.NewRequest(method, url.String(), createBody(body))
397 if err != nil {
398 log.Fatalf("unable to create request: %v", err)
399 }
400 for _, h := range httpHeaders {
401 k, v := headerKeyValue(h)
402 if strings.EqualFold(k, "host") {
403 req.Host = v
404 continue
405 }
406 req.Header.Add(k, v)
407 }
408 return req
409}
410
411func createBody(body string) io.Reader {
412 if strings.HasPrefix(body, "@") {

Callers 1

visitFunction · 0.85

Calls 3

createBodyFunction · 0.85
headerKeyValueFunction · 0.85
StringMethod · 0.80

Tested by

no test coverage detected