Commit 3407834
Changed files (1)
command.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
+ "log"
"net/http"
"os"
"strconv"
@@ -113,7 +114,14 @@ func postRecordsToServer(client *http.Client, recordArray *ClientTest) error {
if err != nil {
return err
}
- _, err = client.Post(clientConfig.SERVER_URL+API_ROOT+"/test?username="+clientConfig.USER, "", bytes.NewBuffer(data))
+ resp, err := client.Post(clientConfig.SERVER_URL+API_ROOT+"/test?username="+clientConfig.USER, "", bytes.NewBuffer(data))
+ defer resp.Body.Close()
+ response, err := ioutil.ReadAll(resp.Body)
+ if resp.StatusCode != http.StatusCreated {
+ log.Printf("Error sending the results to the server: %s", response)
+ } else {
+ fmt.Print("\nTest submitted successfully.")
+ }
return err
}