diff --git a/internal/waf/action_get_302.go b/internal/waf/action_get_302.go index 77ad758..d6b915d 100644 --- a/internal/waf/action_get_302.go +++ b/internal/waf/action_get_302.go @@ -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) - if request.WAFRaw().ProtoMajor == 1 { - flusher, ok := writer.(http.Flusher) - if ok { - flusher.Flush() - } - - request.WAFClose() + flusher, ok := writer.(http.Flusher) + if ok { + flusher.Flush() } + // 延迟等待响应发送完毕 + time.Sleep(1 * time.Second) + request.WAFClose() + return false, false } diff --git a/internal/waf/action_post_307.go b/internal/waf/action_post_307.go index 8342604..ddfabed 100644 --- a/internal/waf/action_post_307.go +++ b/internal/waf/action_post_307.go @@ -6,6 +6,7 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/waf/requests" "github.com/iwind/TeaGo/maps" "github.com/iwind/TeaGo/types" + "io" "net/http" "time" ) @@ -72,10 +73,16 @@ func (this *Post307Action) Perform(waf *WAF, group *RuleGroup, set *RuleSet, req } info, err := utils.SimpleEncryptMap(m) 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 } + // 清空请求内容 + var req = request.WAFRaw() + if req.ContentLength > 0 && req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + // 设置Cookie http.SetCookie(writer, &http.Cookie{ 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) - if request.WAFRaw().ProtoMajor == 1 { - flusher, ok := writer.(http.Flusher) - if ok { - flusher.Flush() - } - - request.WAFClose() + flusher, ok := writer.(http.Flusher) + if ok { + flusher.Flush() } + // 延迟等待响应发送完毕 + time.Sleep(1 * time.Second) + request.WAFClose() + return false, false }