Skip to content

Commit

Permalink
change web driver to use payload string for post
Browse files Browse the repository at this point in the history
  • Loading branch information
deven96 committed Oct 27, 2021
1 parent 4e9b263 commit e43d61f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions driver/web.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package driver

import (
"bytes"
"errors"
"fmt"
"io"
"net/http"
"strconv"
"time"
Expand All @@ -28,8 +28,8 @@ type Web struct {
URL string
// Method POST/GET
Method Request
// Body in case of a POST
Body io.Reader
// Payload in case of a POST
Payload string
}

func (d *Web) String() string {
Expand All @@ -47,11 +47,10 @@ func (d *Web) RunCommand(command string) (string, error) {
var err error
start := time.Now()
if d.Method == POST {
res, err = http.Post(d.URL, "application/json", d.Body)
defer res.Body.Close()
body := []byte(d.Payload)
res, err = http.Post(d.URL, "application/json", bytes.NewBuffer(body))
} else {
res, err = http.Get(d.URL)
defer res.Body.Close()
}
if err != nil || res.StatusCode < 200 || res.StatusCode > 299 {
message := fmt.Sprintf("Error %s running request: %s", err, string(res.StatusCode))
Expand Down
1 change: 1 addition & 0 deletions inspector/process.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package inspector

0 comments on commit e43d61f

Please sign in to comment.