mirror of
https://github.com/chainreactors/spray.git
synced 2025-09-15 11:40:13 +00:00
优化body读取的逻辑, 0byte的body将会自动跳过读取
This commit is contained in:
parent
33da70c457
commit
0b8fed7e80
@ -294,7 +294,6 @@ func (pool *Pool) Invoke(v interface{}) {
|
||||
return
|
||||
}
|
||||
req.SetHeaders(pool.Headers)
|
||||
|
||||
start := time.Now()
|
||||
resp, reqerr := pool.client.Do(pool.ctx, req)
|
||||
if pool.ClientType == ihttp.FAST {
|
||||
|
@ -33,12 +33,16 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
|
||||
copy(bl.Header, header)
|
||||
bl.HeaderLength = len(bl.Header)
|
||||
|
||||
if i := resp.ContentLength(); i != 0 {
|
||||
body := resp.Body()
|
||||
bl.Body = make([]byte, len(body))
|
||||
copy(bl.Body, body)
|
||||
bl.BodyLength = resp.ContentLength()
|
||||
if bl.BodyLength == -1 {
|
||||
|
||||
if i == -1 {
|
||||
bl.BodyLength = len(bl.Body)
|
||||
} else {
|
||||
bl.BodyLength = i
|
||||
}
|
||||
}
|
||||
|
||||
if t, ok := ContentTypeMap[resp.ContentType()]; ok {
|
||||
|
Loading…
x
Reference in New Issue
Block a user