Skip to content

Commit 2f69b98

Browse files
committed
Fix bug where headers were not being added for requests that didn't have post data
1 parent d937576 commit 2f69b98

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

trex/trex.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ import (
88
"encoding/json"
99
"errors"
1010
"fmt"
11-
"github.com/bitly/go-simplejson"
12-
"github.com/gofiber/fiber/v2"
13-
"github.com/steinfletcher/apitest-jsonpath/jsonpath"
14-
"github.com/stretchr/testify/require"
1511
"io"
1612
"net/http"
1713
"net/http/httptest"
1814
"net/url"
1915
"reflect"
2016
"regexp"
2117
"strings"
18+
19+
"github.com/bitly/go-simplejson"
20+
"github.com/gofiber/fiber/v2"
21+
"github.com/steinfletcher/apitest-jsonpath/jsonpath"
22+
"github.com/stretchr/testify/require"
2223
)
2324

2425
func New(s IFiberTestSuite) *TestResponse {
@@ -380,6 +381,12 @@ func createRequest(method, url string, postData *url.Values, headers *http.Heade
380381
var req *http.Request
381382
if postData == nil {
382383
req = httptest.NewRequest(method, url, nil)
384+
if headers != nil {
385+
// add the parameter headers into the requests headers
386+
for key, value := range *headers {
387+
req.Header.Add(key, value[0])
388+
}
389+
}
383390
} else {
384391
if headers != nil && headers.Get(fiber.HeaderContentType) == "application/json" {
385392
req = httptest.NewRequest(method, url, strings.NewReader(convertUrlValuesToJson(postData)))

0 commit comments

Comments
 (0)