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
|
return
|
||||||
}
|
}
|
||||||
req.SetHeaders(pool.Headers)
|
req.SetHeaders(pool.Headers)
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
resp, reqerr := pool.client.Do(pool.ctx, req)
|
resp, reqerr := pool.client.Do(pool.ctx, req)
|
||||||
if pool.ClientType == ihttp.FAST {
|
if pool.ClientType == ihttp.FAST {
|
||||||
|
@ -33,12 +33,16 @@ func NewBaseline(u, host string, resp *ihttp.Response) *Baseline {
|
|||||||
copy(bl.Header, header)
|
copy(bl.Header, header)
|
||||||
bl.HeaderLength = len(bl.Header)
|
bl.HeaderLength = len(bl.Header)
|
||||||
|
|
||||||
body := resp.Body()
|
if i := resp.ContentLength(); i != 0 {
|
||||||
bl.Body = make([]byte, len(body))
|
body := resp.Body()
|
||||||
copy(bl.Body, body)
|
bl.Body = make([]byte, len(body))
|
||||||
bl.BodyLength = resp.ContentLength()
|
copy(bl.Body, body)
|
||||||
if bl.BodyLength == -1 {
|
|
||||||
bl.BodyLength = len(bl.Body)
|
if i == -1 {
|
||||||
|
bl.BodyLength = len(bl.Body)
|
||||||
|
} else {
|
||||||
|
bl.BodyLength = i
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if t, ok := ContentTypeMap[resp.ContentType()]; ok {
|
if t, ok := ContentTypeMap[resp.ContentType()]; ok {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user