Skip to content

Commit

Permalink
feature(backend): defaulting url trigger to http if no scheme is pres…
Browse files Browse the repository at this point in the history
…ent (#2384)
  • Loading branch information
xoscar committed Apr 14, 2023
1 parent 9c41bdc commit fc49f09
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion server/executor/trigger/http.go
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"net"
"net/http"
"net/url"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -81,7 +82,17 @@ func (te *httpTriggerer) Trigger(ctx context.Context, test model.Test, opts *Tri
if tReq.Body != "" {
body = bytes.NewBufferString(tReq.Body)
}
req, err := http.NewRequestWithContext(ctx, strings.ToUpper(string(tReq.Method)), tReq.URL, body)

parsedUrl, err := url.Parse(tReq.URL)
if err != nil {
return response, err
}

if parsedUrl.Scheme == "" {
parsedUrl.Scheme = "http"
}

req, err := http.NewRequestWithContext(ctx, strings.ToUpper(string(tReq.Method)), parsedUrl.String(), body)
if err != nil {
return response, err
}
Expand Down

0 comments on commit fc49f09

Please sign in to comment.