mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-16 07:46:36 +08:00
服务相关流量统计增加Header
This commit is contained in:
@@ -58,8 +58,9 @@ type HTTPWriter struct {
|
||||
|
||||
size int64
|
||||
|
||||
statusCode int
|
||||
sentBodyBytes int64
|
||||
statusCode int
|
||||
sentBodyBytes int64
|
||||
sentHeaderBytes int64
|
||||
|
||||
isOk bool // 是否完全成功
|
||||
isFinished bool // 是否已完成
|
||||
@@ -692,6 +693,23 @@ func (this *HTTPWriter) SentBodyBytes() int64 {
|
||||
return this.sentBodyBytes
|
||||
}
|
||||
|
||||
// SentHeaderBytes 计算发送的Header字节数
|
||||
func (this *HTTPWriter) SentHeaderBytes() int64 {
|
||||
if this.sentHeaderBytes > 0 {
|
||||
return this.sentHeaderBytes
|
||||
}
|
||||
for k, v := range this.Header() {
|
||||
for _, v1 := range v {
|
||||
this.sentHeaderBytes += int64(len(k) + 2 + len(v1) + 1)
|
||||
}
|
||||
}
|
||||
return this.sentHeaderBytes
|
||||
}
|
||||
|
||||
func (this *HTTPWriter) SetSentHeaderBytes(sentHeaderBytes int64) {
|
||||
this.sentHeaderBytes = sentHeaderBytes
|
||||
}
|
||||
|
||||
// WriteHeader 写入状态码
|
||||
func (this *HTTPWriter) WriteHeader(statusCode int) {
|
||||
if this.rawWriter != nil {
|
||||
|
||||
Reference in New Issue
Block a user