From 46e4397e7a65d46719dace8d2e511f11ba3c22eb Mon Sep 17 00:00:00 2001
From: ale <ale@incal.net>
Date: Mon, 28 Aug 2023 17:40:14 +0100
Subject: [PATCH] Allow HTTP probe steps to have names

To simplify debugging.
---
 probes/http/http_probe.go | 8 ++++++--
 protocol/http/step.go     | 1 +
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/probes/http/http_probe.go b/probes/http/http_probe.go
index c0055c1..2288827 100644
--- a/probes/http/http_probe.go
+++ b/probes/http/http_probe.go
@@ -53,9 +53,13 @@ type httpProbe struct {
 func (p *httpProbe) RunProbe(ctx context.Context, debug *log.Logger) error {
 	browser := http.NewBrowser(p.tls, debug, p.dnsMap)
 	for idx, step := range p.script {
-		debug.Printf("sequence step #%d", idx+1)
+		stepName := fmt.Sprintf("#%d", idx+1)
+		if step.Name != "" {
+			stepName = fmt.Sprintf("%s - '%s'", stepName, step.Name)
+		}
+		debug.Printf("sequence step %s", stepName)
 		if err := http.CheckStep(ctx, browser, step, debug); err != nil {
-			err = fmt.Errorf("step #%d failed: %w", idx+1, err)
+			err = fmt.Errorf("step %s failed: %w", stepName, err)
 			debug.Printf("%v", err)
 			return err
 		}
diff --git a/protocol/http/step.go b/protocol/http/step.go
index 1704bc7..abe81f5 100644
--- a/protocol/http/step.go
+++ b/protocol/http/step.go
@@ -17,6 +17,7 @@ type BasicAuth struct {
 // A Step in a script, a series of HTTP transactions whose results we can
 // verify somehow (right now just by needle-in-haystack string matching).
 type Step struct {
+	Name       string            `json:"name"`
 	Type       string            `json:"type"`
 	URL        string            `json:"url"`
 	Method     string            `json:"method"`
-- 
GitLab