mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-15 00:30:24 +08:00
如果源站请求响应中没有Content-Type,则不设置Content-Type
This commit is contained in:
@@ -381,10 +381,19 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if resp == nil {
|
||||||
|
this.write50x(requestErr, http.StatusBadGateway, "Failed to read origin site", "源站读取失败", true)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix Content-Type
|
||||||
|
if resp.Header["Content-Type"] == nil {
|
||||||
|
resp.Header["Content-Type"] = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
// 40x && 50x
|
// 40x && 50x
|
||||||
*failStatusCode = resp.StatusCode
|
*failStatusCode = resp.StatusCode
|
||||||
if resp != nil &&
|
if ((resp.StatusCode >= 500 && resp.StatusCode < 510 && this.reverseProxy.Retry50X) ||
|
||||||
((resp.StatusCode >= 500 && resp.StatusCode < 510 && this.reverseProxy.Retry50X) ||
|
|
||||||
(resp.StatusCode >= 403 && resp.StatusCode <= 404 && this.reverseProxy.Retry40X)) &&
|
(resp.StatusCode >= 403 && resp.StatusCode <= 404 && this.reverseProxy.Retry40X)) &&
|
||||||
(originId > 0 || (lnNodeId > 0 && hasMultipleLnNodes)) &&
|
(originId > 0 || (lnNodeId > 0 && hasMultipleLnNodes)) &&
|
||||||
!isLastRetry {
|
!isLastRetry {
|
||||||
@@ -397,8 +406,7 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 尝试从缓存中恢复
|
// 尝试从缓存中恢复
|
||||||
if resp != nil &&
|
if resp.StatusCode >= 500 && // support 50X only
|
||||||
resp.StatusCode >= 500 && // support 50X only
|
|
||||||
resp.StatusCode < 510 &&
|
resp.StatusCode < 510 &&
|
||||||
this.cacheCanTryStale &&
|
this.cacheCanTryStale &&
|
||||||
this.web.Cache.Stale != nil &&
|
this.web.Cache.Stale != nil &&
|
||||||
|
|||||||
Reference in New Issue
Block a user