aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2021-02-23 20:49:42 -0500
committerAdnan Maolood <[email protected]>2021-02-23 20:49:55 -0500
commite8d98ef4ec9dd9b6fd4f0a67c4ef531485354bee (patch)
tree0d4afa0e2df65848ecb5f7652928d107db716dec /client.go
parentMake ResponseWriter a struct (diff)
downloadgo-gemini-e8d98ef4ec9dd9b6fd4f0a67c4ef531485354bee.tar.xz
go-gemini-e8d98ef4ec9dd9b6fd4f0a67c4ef531485354bee.zip
Move I/O utilities to io.go
Diffstat (limited to 'client.go')
-rw-r--r--client.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/client.go b/client.go
index 5d7e4f5..2020e3d 100644
--- a/client.go
+++ b/client.go
@@ -4,7 +4,6 @@ import (
"context"
"crypto/tls"
"crypto/x509"
- "io"
"net"
"net/url"
"time"
@@ -221,55 +220,3 @@ func punycodeHostname(hostname string) (string, error) {
}
return idna.Lookup.ToASCII(hostname)
}
-
-type contextReader struct {
- ctx context.Context
- done <-chan struct{}
- cancel func()
- rc io.ReadCloser
-}
-
-func (r *contextReader) Read(p []byte) (int, error) {
- select {
- case <-r.done:
- r.rc.Close()
- return 0, r.ctx.Err()
- default:
- }
- n, err := r.rc.Read(p)
- if err != nil {
- r.cancel()
- }
- return n, err
-}
-
-func (r *contextReader) Close() error {
- r.cancel()
- return r.rc.Close()
-}
-
-type contextWriter struct {
- ctx context.Context
- done <-chan struct{}
- cancel func()
- wc io.WriteCloser
-}
-
-func (w *contextWriter) Write(b []byte) (int, error) {
- select {
- case <-w.done:
- w.wc.Close()
- return 0, w.ctx.Err()
- default:
- }
- n, err := w.wc.Write(b)
- if err != nil {
- w.cancel()
- }
- return n, err
-}
-
-func (w *contextWriter) Close() error {
- w.cancel()
- return w.wc.Close()
-}