mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-13 23:10: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/iplibrary"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type BaseClientConn struct {
|
||||
@@ -146,6 +147,8 @@ func (this *BaseClientConn) SetLinger(seconds int) error {
|
||||
|
||||
func (this *BaseClientConn) SetIsPersistent(isPersistent bool) {
|
||||
this.isPersistent = isPersistent
|
||||
|
||||
_ = this.rawConn.SetDeadline(time.Time{})
|
||||
}
|
||||
|
||||
// SetFingerprint 设置指纹信息
|
||||
|
||||
@@ -461,7 +461,19 @@ func (this *HTTPRequest) doOriginRequest(failedOriginIds []int64, failedLnNodeId
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user