Initial commit (code only without large binaries)
This commit is contained in:
50
EdgeNode/internal/nodes/http_writer_ext_plus.go
Normal file
50
EdgeNode/internal/nodes/http_writer_ext_plus.go
Normal file
@@ -0,0 +1,50 @@
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user