Skip to content

Commit

Permalink
Fix: throw error when CONNECT return 5xx
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Oct 5, 2019
1 parent 50d2e08 commit d3c50cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions adapters/outbound/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit d3c50cf

Please sign in to comment.