(args []string, httpVersion string, timeout int)
| 2556 | } |
| 2557 | |
| 2558 | func curlRequest(args []string, httpVersion string, timeout int) Result { |
| 2559 | if len(args) == 0 { |
| 2560 | return Result{} |
| 2561 | } |
| 2562 | |
| 2563 | ctx, cancel := context.WithTimeout(context.Background(), time.Duration(timeout)*time.Millisecond) |
| 2564 | defer cancel() |
| 2565 | |
| 2566 | cmd := exec.CommandContext(ctx, "curl", args...) |
| 2567 | out, err := cmd.Output() |
| 2568 | if err != nil { |
| 2569 | log.Printf("[!] Curl command failed: %v", err) |
| 2570 | return Result{} |
| 2571 | } |
| 2572 | |
| 2573 | return parseCurlOutput(string(out), httpVersion) |
| 2574 | } |
| 2575 | |
| 2576 | func parseCurlOutput(output string, httpVersion string) Result { |
| 2577 | httpVersionOutput := strings.ReplaceAll(httpVersion, "--http", "HTTP/") |
no test coverage detected