MCPcopy Create free account
hub / github.com/httprunner/httprunner / printRequest

Function printRequest

hrp/step_request.go:443–457  ·  view source on GitHub ↗
(req *http.Request)

Source from the content-addressed store, hash-verified

441}
442
443func printRequest(req *http.Request) error {
444 reqContentType := req.Header.Get("Content-Type")
445 printBody := shouldPrintBody(reqContentType)
446 reqDump, err := httputil.DumpRequest(req, printBody)
447 if err != nil {
448 return errors.Wrap(err, "dump request failed")
449 }
450 fmt.Println("-------------------- request --------------------")
451 reqContent := string(reqDump)
452 if reqContentType != "" && !printBody {
453 reqContent += fmt.Sprintf("(request body omitted for Content-Type: %v)", reqContentType)
454 }
455 fmt.Println(reqContent)
456 return nil
457}
458
459func printf(format string, a ...interface{}) (n int, err error) {
460 return fmt.Fprintf(color.Output, format, a...)

Callers 1

runStepRequestFunction · 0.85

Calls 2

shouldPrintBodyFunction · 0.85
GetMethod · 0.80

Tested by

no test coverage detected