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 {
ctx.body = ctx.Body().(*wrapBody)
}
if ctx.StatusCode() != 101 {
if encoding := ctx.ContentEncoding(); encoding != "" {
var unCompressionBody io.ReadCloser
unCompressionBody, err = tools.CompressionHeadersDecode(ctx.Context(), ctx.Body(), encoding)
if err != nil {
if err != io.ErrUnexpectedEOF && err != io.EOF {
return
}
}
if unCompressionBody != nil {
ctx.response.Body = unCompressionBody
if encoding := ctx.ContentEncoding(); encoding != "" {
var unCompressionBody io.ReadCloser
unCompressionBody, err = tools.CompressionHeadersDecode(ctx.Context(), ctx.Body(), encoding)
if err != nil {
if err != io.ErrUnexpectedEOF && err != io.EOF {
return
}
}
if strings.Contains(ctx.response.Header.Get("Content-Type"), "text/event-stream") {
ctx.sse = newSSE(ctx)
if unCompressionBody != nil {
ctx.response.Body = unCompressionBody
}
}
if strings.Contains(ctx.response.Header.Get("Content-Type"), "text/event-stream") {
ctx.sse = newSSE(ctx)
}
return
}