fix header checking

This commit is contained in:
Cyberes 2024-06-02 14:13:54 -06:00
parent e93f353860
commit efefc76929
1 changed files with 5 additions and 5 deletions

View File

@ -51,11 +51,11 @@ func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter,
return "", "", "", "", nil, errors.New(errStr)
}
headerIncludeBrokenThirdparty := req.Header.Get(HeaderThirdpartyIncludeBroken)
headerIncludeBrokenThirdparty := req.Header.Get(HeaderThirdpartyIncludeBroken) != ""
req.Header.Del(HeaderThirdpartyIncludeBroken)
headerBypassThirdparty := req.Header.Get(HeaderThirdpartyBypass)
headerBypassThirdparty := req.Header.Get(HeaderThirdpartyBypass) != ""
req.Header.Del(HeaderThirdpartyBypass)
if headerBypassThirdparty != "" && headerIncludeBrokenThirdparty != "" {
if headerBypassThirdparty && headerIncludeBrokenThirdparty {
errStr := "duplicate options headers detected, rejecting request"
http.Error(w, errStr, http.StatusBadRequest)
return "", "", "", "", nil, errors.New(errStr)
@ -69,9 +69,9 @@ func (p *ForwardProxyCluster) validateRequestAndGetProxy(w http.ResponseWriter,
if slices.Contains(config.GetConfig().ThirdpartyBypassDomains, urlHostname) {
selectedProxy = p.getProxyFromOurs()
} else {
if headerIncludeBrokenThirdparty != "" {
if headerIncludeBrokenThirdparty {
selectedProxy = p.getProxyFromAllWithBroken()
} else if headerBypassThirdparty != "" {
} else if headerBypassThirdparty {
selectedProxy = p.getProxyFromOurs()
} else {
selectedProxy = p.getProxyFromAll()