We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 4f82614 commit c1405c8Copy full SHA for c1405c8
client.go
@@ -3,6 +3,7 @@ package jsh
3
import (
4
"encoding/json"
5
"fmt"
6
+ "io/ioutil"
7
"net/http"
8
"net/url"
9
"strconv"
@@ -32,6 +33,18 @@ func (c *ClientResponse) GetList() ([]*Object, SendableError) {
32
33
return parseMany(c.Header, c.Body)
34
}
35
36
+// BodyStr is a convenience function that parses the body of the response into a
37
+// string BUT DOESN'T close the ReadCloser
38
+func (c *ClientResponse) BodyStr() (string, error) {
39
+
40
+ byteData, err := ioutil.ReadAll(c.Body)
41
+ if err != nil {
42
+ return "", fmt.Errorf("Error attempting to read request body: %s", err)
43
+ }
44
45
+ return string(byteData), nil
46
+}
47
48
// Send sends an http.Request and handles parsing the response back
49
func (r *Request) Send() (*ClientResponse, error) {
50
client := &http.Client{}
0 commit comments