Skip to content

Commit

Permalink
feat: HTTP CONNECT client (fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolaikabanenkov committed Jan 5, 2025
1 parent 474cf4a commit 9869d62
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions x/httpconnect/pipe_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
package httpconnect

import (
"errors"
"github.com/Jigsaw-Code/outline-sdk/transport"
"io"
)

// PipeConn is a [transport.StreamConn] that overrides [Read] and [Write] functions with the given [reader] and [writer]
// PipeConn is a [transport.StreamConn] that overrides [Read], [Write] (and corresponding [Close]) functions with the given [reader] and [writer]
type PipeConn struct {
reader io.Reader
writer io.Writer
reader io.ReadCloser
writer io.WriteCloser
transport.StreamConn
}

Expand All @@ -33,3 +34,15 @@ func (p *PipeConn) Read(b []byte) (n int, err error) {
func (p *PipeConn) Write(b []byte) (n int, err error) {
return p.writer.Write(b)
}

func (p *PipeConn) CloseRead() error {
return errors.Join(p.reader.Close(), p.StreamConn.CloseRead())
}

func (p *PipeConn) CloseWrite() error {
return errors.Join(p.writer.Close(), p.StreamConn.CloseWrite())
}

func (p *PipeConn) Close() error {
return errors.Join(p.reader.Close(), p.writer.Close(), p.StreamConn.Close())
}

0 comments on commit 9869d62

Please sign in to comment.