mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-12 22:40:25 +08:00
优化SSE处理/优化超时设置
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeNode/internal/firewalls"
|
"github.com/TeaOSLab/EdgeNode/internal/firewalls"
|
||||||
"github.com/TeaOSLab/EdgeNode/internal/iplibrary"
|
"github.com/TeaOSLab/EdgeNode/internal/iplibrary"
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BaseClientConn struct {
|
type BaseClientConn struct {
|
||||||
@@ -146,6 +147,8 @@ func (this *BaseClientConn) SetLinger(seconds int) error {
|
|||||||
|
|
||||||
func (this *BaseClientConn) SetIsPersistent(isPersistent bool) {
|
func (this *BaseClientConn) SetIsPersistent(isPersistent bool) {
|
||||||
this.isPersistent = isPersistent
|
this.isPersistent = isPersistent
|
||||||
|
|
||||||
|
_ = this.rawConn.SetDeadline(time.Time{})
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFingerprint 设置指纹信息
|
// SetFingerprint 设置指纹信息
|
||||||
|
|||||||
@@ -461,7 +461,19 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
|||||||
this.ProcessResponseHeaders(this.writer.Header(), resp.StatusCode)
|
this.ProcessResponseHeaders(this.writer.Header(), resp.StatusCode)
|
||||||
|
|
||||||
// 是否需要刷新
|
// 是否需要刷新
|
||||||
var shouldAutoFlush = this.reverseProxy.AutoFlush || this.RawReq.Header.Get("Accept") == "text/event-stream"
|
var shouldAutoFlush = this.reverseProxy.AutoFlush || (resp.Header != nil && strings.Contains(resp.Header.Get("Content-Type"), "stream"))
|
||||||
|
|
||||||
|
// 设置当前连接为Persistence
|
||||||
|
if shouldAutoFlush && this.nodeConfig != nil && this.nodeConfig.HasConnTimeoutSettings() {
|
||||||
|
var requestConn = this.RawReq.Context().Value(HTTPConnContextKey)
|
||||||
|
if requestConn == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requestClientConn, ok := requestConn.(ClientConnInterface)
|
||||||
|
if ok {
|
||||||
|
requestClientConn.SetIsPersistent(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 准备
|
// 准备
|
||||||
var delayHeaders = this.writer.Prepare(resp, resp.ContentLength, resp.StatusCode, true)
|
var delayHeaders = this.writer.Prepare(resp, resp.ContentLength, resp.StatusCode, true)
|
||||||
|
|||||||
@@ -793,7 +793,7 @@ func (this *HTTPWriter) AddHeaders(header http.Header) {
|
|||||||
}
|
}
|
||||||
switch key {
|
switch key {
|
||||||
case "ETag":
|
case "ETag":
|
||||||
newHeaders[key] =value
|
newHeaders[key] = value
|
||||||
default:
|
default:
|
||||||
for _, v := range value {
|
for _, v := range value {
|
||||||
newHeaders.Add(key, v)
|
newHeaders.Add(key, v)
|
||||||
|
|||||||
Reference in New Issue
Block a user