From 31e16d5a4c8a00134f49f9bc176b243bc175303f Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Tue, 23 Feb 2021 15:55:27 -0500 Subject: [PATCH] examples/client: Stream response body --- examples/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/client.go b/examples/client.go index c806a8f..6a4a848 100644 --- a/examples/client.go +++ b/examples/client.go @@ -97,7 +97,8 @@ func do(req *gemini.Request, via []*gemini.Request) (*gemini.Response, error) { client := gemini.Client{ TrustCertificate: trustCertificate, } - resp, err := client.Do(context.Background(), req) + ctx := context.Background() + resp, err := client.Do(ctx, req) if err != nil { return resp, err } @@ -156,11 +157,10 @@ func main() { // Handle response if resp.Status.Class() == gemini.StatusSuccess { - body, err := io.ReadAll(resp.Body) + _, err := io.Copy(os.Stdout, resp.Body) if err != nil { log.Fatal(err) } - fmt.Print(string(body)) } else { fmt.Printf("%d %s\n", resp.Status, resp.Meta) os.Exit(1)