mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
fix multi http parse bug
This commit is contained in:
parent
dc8829ecca
commit
ebc74c1987
@ -1,8 +1,8 @@
|
|||||||
package ihttp
|
package ihttp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"github.com/chainreactors/logs"
|
"github.com/chainreactors/logs"
|
||||||
|
"github.com/chainreactors/utils/httputils"
|
||||||
"github.com/valyala/fasthttp"
|
"github.com/valyala/fasthttp"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -93,15 +93,7 @@ func (r *Response) Header() []byte {
|
|||||||
if r.FastResponse != nil {
|
if r.FastResponse != nil {
|
||||||
return r.FastResponse.Header.Header()
|
return r.FastResponse.Header.Header()
|
||||||
} else if r.StandardResponse != nil {
|
} else if r.StandardResponse != nil {
|
||||||
var header bytes.Buffer
|
return append(httputils.ReadRawHeader(r.StandardResponse), []byte("\r\n")...)
|
||||||
header.WriteString(r.StandardResponse.Proto + " " + r.StandardResponse.Status)
|
|
||||||
for k, v := range r.StandardResponse.Header {
|
|
||||||
for _, i := range v {
|
|
||||||
header.WriteString(k + ": " + i + "\r\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
header.WriteString("\r\n")
|
|
||||||
return header.Bytes()
|
|
||||||
} else {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -36,9 +36,10 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
|
|||||||
bl.HeaderLength = len(bl.Header)
|
bl.HeaderLength = len(bl.Header)
|
||||||
|
|
||||||
if i := resp.ContentLength(); ihttp.CheckBodySize(i) {
|
if i := resp.ContentLength(); ihttp.CheckBodySize(i) {
|
||||||
body := resp.Body()
|
if body := resp.Body(); body != nil {
|
||||||
bl.Body = make([]byte, len(body))
|
bl.Body = make([]byte, len(body))
|
||||||
copy(bl.Body, body)
|
copy(bl.Body, body)
|
||||||
|
}
|
||||||
|
|
||||||
if i == -1 {
|
if i == -1 {
|
||||||
bl.Chunked = true
|
bl.Chunked = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user