From 3bbc10796c1bc356d6698bd320823ef1377f6fdd Mon Sep 17 00:00:00 2001 From: ginuerzh Date: Wed, 30 Jul 2025 10:06:52 +0800 Subject: [PATCH] http2: added non-connect request support --- handler/http2/handler.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/handler/http2/handler.go b/handler/http2/handler.go index 55e0db9b..670aad68 100644 --- a/handler/http2/handler.go +++ b/handler/http2/handler.go @@ -323,9 +323,15 @@ func (h *http2Handler) roundTrip(ctx context.Context, w http.ResponseWriter, req return nil } - // TODO: forward request - resp.StatusCode = http.StatusBadRequest - w.WriteHeader(resp.StatusCode) + start := time.Now() + log.Infof("%s <-> %s", req.RemoteAddr, host) + if err := h.forwardRequest(w, req, cc); err != nil { + log.Info("%s - %s: %s", req.RemoteAddr, host, err) + } + log.WithFields(map[string]any{ + "duration": time.Since(start), + }).Infof("%s >-< %s", req.RemoteAddr, host) + return nil } @@ -456,6 +462,7 @@ func (h *http2Handler) authenticate(ctx context.Context, w http.ResponseWriter, return } + func (h *http2Handler) forwardRequest(w http.ResponseWriter, r *http.Request, rw io.ReadWriter) (err error) { if err = r.Write(rw); err != nil { return