File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package jsh
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
+ "io/ioutil"
6
7
"net/http"
7
8
"net/url"
8
9
"strconv"
@@ -32,6 +33,18 @@ func (c *ClientResponse) GetList() ([]*Object, SendableError) {
32
33
return parseMany (c .Header , c .Body )
33
34
}
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
+
35
48
// Send sends an http.Request and handles parsing the response back
36
49
func (r * Request ) Send () (* ClientResponse , error ) {
37
50
client := & http.Client {}
You can’t perform that action at this time.
0 commit comments