diff options
author | tjpcc <tjp@ctrl-c.club> | 2023-05-09 10:19:51 -0600 |
---|---|---|
committer | tjpcc <tjp@ctrl-c.club> | 2023-05-09 10:19:51 -0600 |
commit | c754a4406455936dd8ab6d0278fc6423f2fbf2cc (patch) | |
tree | e9e043ff4bb8bcaa438ec3235a8188610c697a36 /examples/fetch/main.go | |
parent | 45c2beece021db32c47a32f5e45573307e2edd73 (diff) |
InsecureSkipVerify and other improvements for the gemini fetch example code
Diffstat (limited to 'examples/fetch/main.go')
-rw-r--r-- | examples/fetch/main.go | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/fetch/main.go b/examples/fetch/main.go index fccc6cf..8f03114 100644 --- a/examples/fetch/main.go +++ b/examples/fetch/main.go @@ -30,7 +30,7 @@ func main() { } // parse the URL and build the request - request := &sr.Request{URL: buildURL()} + request := &sr.Request{URL: buildURL(os.Args[1])} // fetch the response response, err := client.RoundTrip(request) @@ -43,17 +43,16 @@ func main() { log.Fatalf("%d %s\n", response.Status, response.Meta) } - //io.Copy(os.Stdout, response) - buf, err := io.ReadAll(gemini.NewResponseReader(response)) - fmt.Printf("response: %s\n", buf) + if _, err := io.Copy(os.Stdout, response.Body); err != nil { + log.Fatal(err) + } } func envConfig() (string, string) { - return os.Getenv("SERVER_CERTIFICATE"), os.Getenv("SERVER_PRIVATEKEY") + return os.Getenv("CLIENT_CERTIFICATE"), os.Getenv("CLIENT_PRIVATEKEY") } -func buildURL() *url.URL { - raw := os.Args[1] +func buildURL(raw string) *url.URL { if strings.HasPrefix(raw, "//") { raw = "gemini:" + raw } |