This commit is contained in:
gospider
2025-03-24 16:58:37 +08:00
parent 2e471ea7f7
commit aa18032511
5 changed files with 30 additions and 48 deletions

View File

@@ -246,7 +246,7 @@ func (obj *Response) SetContent(val []byte) {
// return content with []byte
func (obj *Response) Content() []byte {
if !obj.IsWebSocket() && !obj.IsSSE() {
if obj.webSocket == nil && obj.sse == nil {
obj.ReadBody()
}
return obj.content
@@ -305,19 +305,6 @@ func (obj *Response) Body() io.ReadCloser {
return obj.response.Body
}
// return true if response is stream
func (obj *Response) IsStream() bool {
return obj.option.Stream
}
// return true if response is other stream
func (obj *Response) IsWebSocket() bool {
return obj.webSocket != nil
}
func (obj *Response) IsSSE() bool {
return obj.sse != nil
}
// read body
func (obj *Response) ReadBody() (err error) {
obj.readBodyLock.Lock()