Skip to content

Commit

Permalink
use the http3.CapsuleProtocolHeader instead of redefining it (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann authored Nov 12, 2024
1 parent 892f6e9 commit 321f13c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Dial(ctx context.Context, conn *http3.ClientConn, template *uritemplate.Tem
Method: http.MethodConnect,
Proto: requestProtocol,
Host: u.Host,
Header: http.Header{capsuleHeader: []string{capsuleProtocolHeaderValue}},
Header: http.Header{http3.CapsuleProtocolHeader: []string{capsuleProtocolHeaderValue}},
URL: u,
}); err != nil {
return nil, nil, fmt.Errorf("connect-ip: failed to send request: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var contextIDZero = quicvarint.Append([]byte{}, 0)
type Proxy struct{}

func (s *Proxy) Proxy(w http.ResponseWriter, _ *Request) (*Conn, error) {
w.Header().Set(capsuleHeader, capsuleProtocolHeaderValue)
w.Header().Set(http3.CapsuleProtocolHeader, capsuleProtocolHeaderValue)
w.WriteHeader(http.StatusOK)

str := w.(http3.HTTPStreamer).HTTPStream()
Expand Down
8 changes: 3 additions & 5 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ import (
"reflect"

"github.com/dunglas/httpsfv"
"github.com/quic-go/quic-go/http3"
"github.com/yosida95/uritemplate/v3"
)

const (
requestProtocol = "connect-ip"
capsuleHeader = "Capsule-Protocol"
)
const requestProtocol = "connect-ip"

var capsuleProtocolHeaderValue string

Expand Down Expand Up @@ -70,7 +68,7 @@ func ParseRequest(r *http.Request, template *uritemplate.Template) (*Request, er
Err: fmt.Errorf("host in :authority (%s) does not match template host (%s)", r.Host, u.Host),
}
}
capsuleHeaderValues, ok := r.Header[capsuleHeader]
capsuleHeaderValues, ok := r.Header[http3.CapsuleProtocolHeader]
if !ok {
return nil, &RequestParseError{
HTTPStatus: http.StatusBadRequest,
Expand Down

0 comments on commit 321f13c

Please sign in to comment.