httpjson: add unit test to verify that POST params get passed

This commit is contained in:
Cameron Sparr
2016-02-23 10:54:28 -07:00
parent 69e4f16b13
commit 3e8f96a463
2 changed files with 149 additions and 9 deletions

View File

@@ -1,7 +1,6 @@
package httpjson
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
@@ -183,11 +182,10 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
return "", -1, fmt.Errorf("Invalid server URL \"%s\"", serverURL)
}
params := url.Values{}
data := url.Values{}
switch {
case h.Method == "GET":
params := requestURL.Query()
for k, v := range h.Parameters {
params.Add(k, v)
}
@@ -201,7 +199,8 @@ func (h *HttpJson) sendRequest(serverURL string) (string, float64, error) {
}
// Create + send request
req, err := http.NewRequest(h.Method, requestURL.String(), bytes.NewBufferString(data.Encode()))
req, err := http.NewRequest(h.Method, requestURL.String(),
strings.NewReader(data.Encode()))
if err != nil {
return "", -1, err
}