mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-12-15 15:16:35 +08:00
修复因为WAF而导致Content-Length没有显式设置的问题
This commit is contained in:
@@ -23,13 +23,17 @@ func (this *Request) Raw() *http.Request {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *Request) ReadBody(max int64) (data []byte, err error) {
|
func (this *Request) ReadBody(max int64) (data []byte, err error) {
|
||||||
data, err = ioutil.ReadAll(io.LimitReader(this.Request.Body, max))
|
if this.Request.ContentLength > 0 {
|
||||||
|
data, err = ioutil.ReadAll(io.LimitReader(this.Request.Body, max))
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Request) RestoreBody(data []byte) {
|
func (this *Request) RestoreBody(data []byte) {
|
||||||
rawReader := bytes.NewBuffer(data)
|
if len(data) > 0 {
|
||||||
buf := make([]byte, 1024)
|
rawReader := bytes.NewBuffer(data)
|
||||||
io.CopyBuffer(rawReader, this.Request.Body, buf)
|
buf := make([]byte, 1024)
|
||||||
this.Request.Body = ioutil.NopCloser(rawReader)
|
_, _ = io.CopyBuffer(rawReader, this.Request.Body, buf)
|
||||||
|
this.Request.Body = ioutil.NopCloser(rawReader)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user