mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-30 12:20:25 +08:00
实现记录请求Body
This commit is contained in:
@@ -7,6 +7,11 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
// AccessLogMaxRequestBodySize 访问日志存储的请求内容最大尺寸 TODO 此值应该可以在访问日志页设置
|
||||
AccessLogMaxRequestBodySize = 2 * 1024 * 1024
|
||||
)
|
||||
|
||||
// 日志
|
||||
func (this *HTTPRequest) log() {
|
||||
if this.disableLog {
|
||||
@@ -140,6 +145,15 @@ func (this *HTTPRequest) log() {
|
||||
accessLog.OriginAddress = this.originAddr
|
||||
}
|
||||
|
||||
// 请求Body
|
||||
if ref.ContainsField(serverconfigs.HTTPAccessLogFieldRequestBody) {
|
||||
accessLog.RequestBody = this.requestBodyData
|
||||
|
||||
if len(accessLog.RequestBody) > AccessLogMaxRequestBodySize {
|
||||
accessLog.RequestBody = accessLog.RequestBody[:AccessLogMaxRequestBodySize]
|
||||
}
|
||||
}
|
||||
|
||||
// TODO 记录匹配的 locationId和rewriteId
|
||||
|
||||
sharedHTTPAccessLogQueue.Push(accessLog)
|
||||
|
||||
Reference in New Issue
Block a user