This commit is contained in:
gospider
2025-04-10 22:20:43 +08:00
parent 9d856633dd
commit c8596b09bc

View File

@@ -346,22 +346,20 @@ func (obj *Client) request(ctx *Response) (err error) {
if ctx.Body() != nil { if ctx.Body() != nil {
ctx.body = ctx.Body().(*wrapBody) ctx.body = ctx.Body().(*wrapBody)
} }
if ctx.StatusCode() != 101 { if encoding := ctx.ContentEncoding(); encoding != "" {
if encoding := ctx.ContentEncoding(); encoding != "" { var unCompressionBody io.ReadCloser
var unCompressionBody io.ReadCloser unCompressionBody, err = tools.CompressionHeadersDecode(ctx.Context(), ctx.Body(), encoding)
unCompressionBody, err = tools.CompressionHeadersDecode(ctx.Context(), ctx.Body(), encoding) if err != nil {
if err != nil { if err != io.ErrUnexpectedEOF && err != io.EOF {
if err != io.ErrUnexpectedEOF && err != io.EOF { return
return
}
}
if unCompressionBody != nil {
ctx.response.Body = unCompressionBody
} }
} }
if strings.Contains(ctx.response.Header.Get("Content-Type"), "text/event-stream") { if unCompressionBody != nil {
ctx.sse = newSSE(ctx) ctx.response.Body = unCompressionBody
} }
} }
if strings.Contains(ctx.response.Header.Get("Content-Type"), "text/event-stream") {
ctx.sse = newSSE(ctx)
}
return return
} }