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 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
} }

View File

@ -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