Skip to content

Commit e43d61f

Browse files
committed
change web driver to use payload string for post
1 parent 4e9b263 commit e43d61f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

driver/web.go

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package driver
22

33
import (
4+
"bytes"
45
"errors"
56
"fmt"
6-
"io"
77
"net/http"
88
"strconv"
99
"time"
@@ -28,8 +28,8 @@ type Web struct {
2828
URL string
2929
// Method POST/GET
3030
Method Request
31-
// Body in case of a POST
32-
Body io.Reader
31+
// Payload in case of a POST
32+
Payload string
3333
}
3434

3535
func (d *Web) String() string {
@@ -47,11 +47,10 @@ func (d *Web) RunCommand(command string) (string, error) {
4747
var err error
4848
start := time.Now()
4949
if d.Method == POST {
50-
res, err = http.Post(d.URL, "application/json", d.Body)
51-
defer res.Body.Close()
50+
body := []byte(d.Payload)
51+
res, err = http.Post(d.URL, "application/json", bytes.NewBuffer(body))
5252
} else {
5353
res, err = http.Get(d.URL)
54-
defer res.Body.Close()
5554
}
5655
if err != nil || res.StatusCode < 200 || res.StatusCode > 299 {
5756
message := fmt.Sprintf("Error %s running request: %s", err, string(res.StatusCode))

inspector/process.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package inspector

0 commit comments

Comments
 (0)