From d3c50cf89fb74f02e91211226009a2cd924a72ec Mon Sep 17 00:00:00 2001 From: Dreamacro <305009791@qq.com> Date: Sat, 5 Oct 2019 09:33:40 +0800 Subject: [PATCH] Fix: throw error when CONNECT return 5xx --- adapters/outbound/http.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/adapters/outbound/http.go b/adapters/outbound/http.go index 9b3791f0..12b80a5b 100644 --- a/adapters/outbound/http.go +++ b/adapters/outbound/http.go @@ -81,17 +81,21 @@ func (h *Http) shakeHand(metadata *C.Metadata, rw io.ReadWriter) error { return err } - if resp.StatusCode == 200 { + if resp.StatusCode == http.StatusOK { return nil } - if resp.StatusCode == 407 { + if resp.StatusCode == http.StatusProxyAuthRequired { return errors.New("HTTP need auth") } - if resp.StatusCode == 405 { + if resp.StatusCode == http.StatusMethodNotAllowed { return errors.New("CONNECT method not allowed by proxy") } + + if resp.StatusCode >= http.StatusInternalServerError { + return errors.New(resp.Status) + } return fmt.Errorf("can not connect remote err code: %d", resp.StatusCode) }