mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-10 20:10:24 +08:00
修复内容为空时无法缓存的Bug
This commit is contained in:
@@ -328,7 +328,12 @@ func (this *HTTPRequest) doReverseProxy() {
|
|||||||
|
|
||||||
// 是否有内容
|
// 是否有内容
|
||||||
if resp.ContentLength == 0 && len(resp.TransferEncoding) == 0 {
|
if resp.ContentLength == 0 && len(resp.TransferEncoding) == 0 {
|
||||||
|
// 即使内容为0,也需要读取一次,以便于触发相关事件
|
||||||
|
var buf = utils.BytePool4k.Get()
|
||||||
|
_, _ = io.CopyBuffer(this.writer, resp.Body, buf)
|
||||||
|
utils.BytePool4k.Put(buf)
|
||||||
_ = resp.Body.Close()
|
_ = resp.Body.Close()
|
||||||
|
|
||||||
this.writer.SetOk()
|
this.writer.SetOk()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ func (this *HTTPWriter) HeaderData() []byte {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := &http.Response{}
|
var resp = &http.Response{}
|
||||||
resp.Header = this.Header()
|
resp.Header = this.Header()
|
||||||
if this.statusCode == 0 {
|
if this.statusCode == 0 {
|
||||||
this.statusCode = http.StatusOK
|
this.statusCode = http.StatusOK
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
package readers
|
package readers
|
||||||
|
|
||||||
import "io"
|
import (
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
type TeeReaderCloser struct {
|
type TeeReaderCloser struct {
|
||||||
r io.Reader
|
r io.Reader
|
||||||
|
|||||||
Reference in New Issue
Block a user