From 98772224c20976b4d67d811ebdaff6b941c74408 Mon Sep 17 00:00:00 2001 From: zema1 Date: Tue, 13 Jun 2023 17:32:46 +0800 Subject: [PATCH] fix: allow eof in checkConnectMode --- ctrl/config.go | 2 +- ctrl/ctrl.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ctrl/config.go b/ctrl/config.go index 5a166e8..62e3f48 100644 --- a/ctrl/config.go +++ b/ctrl/config.go @@ -43,7 +43,7 @@ func (s *Suo5Config) parseHeader() error { if len(parts) != 2 { return fmt.Errorf("invalid header value %s", value) } - s.Header.Set(parts[0], parts[1]) + s.Header.Set(strings.TrimSpace(parts[0]), strings.TrimSpace(parts[1])) } return nil } diff --git a/ctrl/ctrl.go b/ctrl/ctrl.go index 3239a34..65061b7 100644 --- a/ctrl/ctrl.go +++ b/ctrl/ctrl.go @@ -231,7 +231,8 @@ func checkConnectMode(method string, target string, baseHeader http.Header, prox // 如果独到响应的时间在3s内,说明请求没有被缓存, 那么就可以变成全双工的 body, err := ioutil.ReadAll(resp.Body) if err != nil { - return Undefined, 0, err + // 这里不要直接返回,有时虽然 eof 了但是数据是对的,可以使用 + log.Warnf("got error %s", err) } duration := time.Since(now).Milliseconds()