aboutsummaryrefslogtreecommitdiff
path: root/examples/client.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-10-27 19:16:55 -0400
committerAdnan Maolood <[email protected]>2020-10-27 19:16:55 -0400
commit12a9deb1a64108058d8ccd75705f95471f458cd0 (patch)
tree4e0c7e7fc3636d51430d6f223dc39ad927afca62 /examples/client.go
parentFix examples (diff)
downloadarchived-go-gemini-12a9deb1a64108058d8ccd75705f95471f458cd0.tar.xz
archived-go-gemini-12a9deb1a64108058d8ccd75705f95471f458cd0.zip
Make (*Response).Body an io.ReadCloser
Diffstat (limited to 'examples/client.go')
-rw-r--r--examples/client.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/examples/client.go b/examples/client.go
index 659e783..fa88dcf 100644
--- a/examples/client.go
+++ b/examples/client.go
@@ -7,6 +7,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
+ "io/ioutil"
"net/url"
"os"
"time"
@@ -80,7 +81,12 @@ func sendRequest(req *gmi.Request) error {
req.URL.RawQuery = url.QueryEscape(scanner.Text())
return sendRequest(req)
case gmi.StatusClassSuccess:
- fmt.Print(string(resp.Body))
+ defer resp.Body.Close()
+ body, err := ioutil.ReadAll(resp.Body)
+ if err != nil {
+ return err
+ }
+ fmt.Print(string(body))
return nil
case gmi.StatusClassRedirect:
fmt.Println("Redirecting to", resp.Meta)