aboutsummaryrefslogtreecommitdiff
path: root/doc.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-11-08 18:38:08 -0500
committerAdnan Maolood <[email protected]>2020-11-08 18:38:08 -0500
commit5332dc628043a5c0d18652ebf4b89576de7af653 (patch)
tree5ad63d218219c2e5979850a44d00de92f9297d61 /doc.go
parentFix relative redirects (diff)
downloadgo-gemini-5332dc628043a5c0d18652ebf4b89576de7af653.tar.xz
go-gemini-5332dc628043a5c0d18652ebf4b89576de7af653.zip
Don't guarantee that (*Response).Body is always non-nil
Diffstat (limited to 'doc.go')
-rw-r--r--doc.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/doc.go b/doc.go
index 944adbb..ea988ef 100644
--- a/doc.go
+++ b/doc.go
@@ -7,7 +7,10 @@ Get makes a Gemini request:
if err != nil {
// handle error
}
- defer resp.Body.Close()
+ if resp.Status.Class() == gemini.StatusClassSucess {
+ defer resp.Body.Close()
+ // ...
+ }
// ...
For control over client behavior, create a Client: