Files
waf-platform/EdgeNode/internal/nodes/http_writer_ext_plus.go
2026-02-04 20:27:13 +08:00

51 lines
1.1 KiB
Go

// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
//go:build plus
// +build plus
package nodes
import (
"github.com/TeaOSLab/EdgeNode/internal/caches"
"github.com/TeaOSLab/EdgeNode/internal/utils/writers"
"io"
"os"
)
func (this *HTTPWriter) canSendfile() (*os.File, bool) {
if this.cacheWriter != nil || this.webpIsEncoding || this.isPartial || this.delayRead || this.compressionCacheWriter != nil {
return nil, false
}
if this.rawReader == nil {
return nil, false
}
fileReader, ok := this.rawReader.(*caches.FileReader)
if !ok {
return nil, false
}
_, ok = this.rawWriter.(io.ReaderFrom)
if !ok {
return nil, false
}
counterWriter, ok := this.writer.(*writers.BytesCounterWriter)
if !ok {
return nil, false
}
if counterWriter.RawWriter() != this.rawWriter {
return nil, false
}
return fileReader.FP(), true
}
// 检查套餐带宽限速
func (this *HTTPWriter) checkPlanBandwidth(n int) {
if this.req.ReqServer != nil && this.req.ReqServer.PlanId() > 0 {
sharedPlanBandwidthLimiter.Ack(this.req.RawReq.Context(), this.req.ReqServer.PlanId(), n)
}
}