Archived
修复GET302和POST307关闭连接后无法响应的问题
This commit is contained in:
@@ -69,14 +69,14 @@ func (this *Get302Action) Perform(waf *WAF, group *RuleGroup, set *RuleSet, requ
|
|||||||
|
|
||||||
http.Redirect(writer, request.WAFRaw(), Get302Path+"?info="+url.QueryEscape(info), http.StatusFound)
|
http.Redirect(writer, request.WAFRaw(), Get302Path+"?info="+url.QueryEscape(info), http.StatusFound)
|
||||||
|
|
||||||
if request.WAFRaw().ProtoMajor == 1 {
|
flusher, ok := writer.(http.Flusher)
|
||||||
flusher, ok := writer.(http.Flusher)
|
if ok {
|
||||||
if ok {
|
flusher.Flush()
|
||||||
flusher.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
request.WAFClose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 延迟等待响应发送完毕
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
request.WAFClose()
|
||||||
|
|
||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
"github.com/TeaOSLab/EdgeNode/internal/waf/requests"
|
||||||
"github.com/iwind/TeaGo/maps"
|
"github.com/iwind/TeaGo/maps"
|
||||||
"github.com/iwind/TeaGo/types"
|
"github.com/iwind/TeaGo/types"
|
||||||
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@@ -72,10 +73,16 @@ func (this *Post307Action) Perform(waf *WAF, group *RuleGroup, set *RuleSet, req
|
|||||||
}
|
}
|
||||||
info, err := utils.SimpleEncryptMap(m)
|
info, err := utils.SimpleEncryptMap(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
remotelogs.Error("WAF_POST_302_ACTION", "encode info failed: "+err.Error())
|
remotelogs.Error("WAF_POST_307_ACTION", "encode info failed: "+err.Error())
|
||||||
return true, false
|
return true, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清空请求内容
|
||||||
|
var req = request.WAFRaw()
|
||||||
|
if req.ContentLength > 0 && req.Body != nil {
|
||||||
|
_, _ = io.Copy(io.Discard, req.Body)
|
||||||
|
}
|
||||||
|
|
||||||
// 设置Cookie
|
// 设置Cookie
|
||||||
http.SetCookie(writer, &http.Cookie{
|
http.SetCookie(writer, &http.Cookie{
|
||||||
Name: cookieName,
|
Name: cookieName,
|
||||||
@@ -86,14 +93,14 @@ func (this *Post307Action) Perform(waf *WAF, group *RuleGroup, set *RuleSet, req
|
|||||||
|
|
||||||
http.Redirect(writer, request.WAFRaw(), request.WAFRaw().URL.String(), http.StatusTemporaryRedirect)
|
http.Redirect(writer, request.WAFRaw(), request.WAFRaw().URL.String(), http.StatusTemporaryRedirect)
|
||||||
|
|
||||||
if request.WAFRaw().ProtoMajor == 1 {
|
flusher, ok := writer.(http.Flusher)
|
||||||
flusher, ok := writer.(http.Flusher)
|
if ok {
|
||||||
if ok {
|
flusher.Flush()
|
||||||
flusher.Flush()
|
|
||||||
}
|
|
||||||
|
|
||||||
request.WAFClose()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 延迟等待响应发送完毕
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
|
request.WAFClose()
|
||||||
|
|
||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user