Skip to content

Commit

Permalink
Merge pull request #20 from socotra/release/v0.0.8
Browse files Browse the repository at this point in the history
v0.0.8 into internal/master
  • Loading branch information
ivan-velasco authored Dec 12, 2024
2 parents 611a0ce + c65c15c commit 69c2b24
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.7
v0.0.8
36 changes: 32 additions & 4 deletions executors/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,45 @@ func (Executor) Run(ctx context.Context, step venom.TestStep) (interface{}, erro

result := Result{}

varsMap := venom.AllVarsFromCtx(ctx)

// Initialize Headers if it's nil
if e.Headers == nil {
e.Headers = make(Headers)
}

// Extract and set all headers that start with "header_"
for k, v := range varsMap {
if strings.HasPrefix(k, "header_") {
headerName := strings.TrimPrefix(k, "header_")
headerValue := fmt.Sprintf("%v", v)
e.setDefaultHeader(headerName, headerValue)
venom.Debug(ctx, "Configured header '%s' with value '%s'", headerName, headerValue)
}
}

// If authentication format and value are provided, set the Authorization header
if authFormat, okFormat := varsMap["auth_format"]; okFormat {
if authValue, okValue := varsMap["auth_value"]; okValue {
authHeader := fmt.Sprintf("%v %v", authFormat, authValue)
e.setDefaultHeader("Authorization", authHeader)
venom.Debug(ctx, "Configured 'Authorization' header")
}
}

// If MultipartForm is detected, remove the Content-Type header, as it may be set automatically
if e.MultipartForm != nil {
delete(e.Headers, "Content-Type")
venom.Debug(ctx, "MultipartForm detected, removed 'Content-Type' header")
}

workdir := venom.StringVarFromCtx(ctx, "venom.testsuite.workdir")

req, err := e.getRequest(ctx, workdir)
if err != nil {
return nil, err
}

if e.MultipartForm == nil {
e.setDefaultHeader("Content-Type", "application/json")
}

for k, v := range e.Headers {
req.Header.Set(k, v)
if strings.ToLower(k) == "host" {
Expand Down

0 comments on commit 69c2b24

Please sign in to comment.