MCPcopy Create free account
hub / github.com/keploy/keploy / MakeCurlCommand

Function MakeCurlCommand

pkg/util.go:2592–2615  ·  view source on GitHub ↗
(tc models.HTTPReq)

Source from the content-addressed store, hash-verified

2590}
2591
2592func MakeCurlCommand(tc models.HTTPReq) string {
2593 curl := fmt.Sprintf("curl --request %s \\\n", string(tc.Method))
2594 curl = curl + fmt.Sprintf(" --url %s \\\n", tc.URL)
2595 header := ToHTTPHeader(tc.Header)
2596
2597 for k, v := range ToYamlHTTPHeader(header) {
2598 if k != "Content-Length" {
2599 curl = curl + fmt.Sprintf(" --header '%s: %s' \\\n", k, v)
2600 }
2601 }
2602 if len(tc.Form) > 0 {
2603 for _, form := range tc.Form {
2604 key := form.Key
2605 if len(form.Values) == 0 {
2606 continue
2607 }
2608 value := form.Values[0]
2609 curl = curl + fmt.Sprintf(" --form '%s=%s' \\\n", key, value)
2610 }
2611 } else if tc.Body != "" {
2612 curl = curl + fmt.Sprintf(" --data %s", strconv.Quote(tc.Body))
2613 }
2614 return curl
2615}
2616
2617func ReadSessionIndices(path string, Logger *zap.Logger) ([]string, error) {
2618 indices := []string{}

Callers 3

StartMethod · 0.92
writeTestDataMethod · 0.92
InsertTestCaseMethod · 0.92

Calls 2

ToHTTPHeaderFunction · 0.85
ToYamlHTTPHeaderFunction · 0.85

Tested by

no test coverage detected