refactor(handler/http2): split handler into 3 focused files with 52 tests

Extract authenticate/probe-resistance to auth.go and roundTrip/forwarding
to proxy.go, following the handler/http/ pattern. Export sentinel errors
(ErrAuthFailed, ErrWrongConnType) for precise test assertions. Fix
flushWriter panic recovery to handle non-string/non-error panics. Default
HTTPS port to 443 when no port is specified in the Host header.
This commit is contained in:
ginuerzh
2026-05-30 18:01:19 +08:00
parent a33c6f4a92
commit 6ccaae0573
11 changed files with 1228 additions and 382 deletions
+8 -4
View File
@@ -2,6 +2,7 @@ package http2
import (
"errors"
"fmt"
"io"
"net/http"
)
@@ -13,11 +14,14 @@ type flushWriter struct {
func (fw flushWriter) Write(p []byte) (n int, err error) {
defer func() {
if r := recover(); r != nil {
if s, ok := r.(string); ok {
err = errors.New(s)
return
switch v := r.(type) {
case string:
err = errors.New(v)
case error:
err = v
default:
err = fmt.Errorf("%v", v)
}
err = r.(error)
}
}()