fix multi http parse bug

This commit is contained in:
M09Ic 2024-08-06 03:46:30 +08:00
parent dc8829ecca
commit ebc74c1987
2 changed files with 6 additions and 13 deletions

View File

@ -1,8 +1,8 @@
package ihttp
import (
"bytes"
"github.com/chainreactors/logs"
"github.com/chainreactors/utils/httputils"
"github.com/valyala/fasthttp"
"io"
"net/http"
@ -93,15 +93,7 @@ func (r *Response) Header() []byte {
if r.FastResponse != nil {
return r.FastResponse.Header.Header()
} else if r.StandardResponse != nil {
var header bytes.Buffer
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()
return append(httputils.ReadRawHeader(r.StandardResponse), []byte("\r\n")...)
} else {
return nil
}

View File

@ -36,9 +36,10 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
bl.HeaderLength = len(bl.Header)
if i := resp.ContentLength(); ihttp.CheckBodySize(i) {
body := resp.Body()
if body := resp.Body(); body != nil {
bl.Body = make([]byte, len(body))
copy(bl.Body, body)
}
if i == -1 {
bl.Chunked = true