diff --git a/go.mod b/go.mod index 5c5df3a..2c3e72d 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/gospider007/ja3 v0.0.0-20231029025157-38fc2f8f2d91 github.com/gospider007/net v0.0.0-20231028084010-313c148cf0a1 github.com/gospider007/re v0.0.0-20231024115818-adfd03636256 - github.com/gospider007/tools v0.0.0-20231120122411-d631cc2fc371 + github.com/gospider007/tools v0.0.0-20231122021245-1cafbac3ef46 github.com/gospider007/websocket v0.0.0-20231114095858-b8bc9b2033d3 github.com/refraction-networking/utls v1.5.4 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa diff --git a/go.sum b/go.sum index 1e0d4a3..b664116 100644 --- a/go.sum +++ b/go.sum @@ -49,6 +49,8 @@ github.com/gospider007/re v0.0.0-20231024115818-adfd03636256 h1:Z6kHRANoWB+/4rDz github.com/gospider007/re v0.0.0-20231024115818-adfd03636256/go.mod h1:X58uk0/F3mVskuQOZng0ZKJiAt3ETn0wxuLN//rVZrE= github.com/gospider007/tools v0.0.0-20231120122411-d631cc2fc371 h1:wF5pm7gilDuDKg4rmhmz4S+/Y3EEVgvZdwgywnhbyKA= github.com/gospider007/tools v0.0.0-20231120122411-d631cc2fc371/go.mod h1:myK4kDqDx4TlplDVnfYMI7Xi5VUbFZ3fxwAh2Cwm7ks= +github.com/gospider007/tools v0.0.0-20231122021245-1cafbac3ef46 h1:vskdS8WLAveNSDHsAAdwiD+LBLMHq3AND1nGnVydwfM= +github.com/gospider007/tools v0.0.0-20231122021245-1cafbac3ef46/go.mod h1:myK4kDqDx4TlplDVnfYMI7Xi5VUbFZ3fxwAh2Cwm7ks= github.com/gospider007/websocket v0.0.0-20231114095858-b8bc9b2033d3 h1:HpiNfOZ9Tjo4hhP1+jmlgqykngykles3ypXa2BUuxRc= github.com/gospider007/websocket v0.0.0-20231114095858-b8bc9b2033d3/go.mod h1:jINjCM6qIRiqn2Di1bat4Ie5gY66ae7LYT8YK4fAejY= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= diff --git a/requests.go b/requests.go index f7823d8..9658fe9 100644 --- a/requests.go +++ b/requests.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "io" "log" "net" "runtime" @@ -435,11 +436,15 @@ func (obj *Client) request(ctx context.Context, option *RequestOption) (response } else if response.response.Header.Get("Content-Type") == "text/event-stream" { response.sse = newSse(response.response.Body, response.CloseConn) } else if !response.disUnzip { - if ctxData.debug { - + var unCompressionBody io.ReadCloser + unCompressionBody, err = tools.CompressionDecode(response.response.Body, response.ContentEncoding()) + if err != nil { + if err != io.ErrUnexpectedEOF && err != io.EOF { + return + } } - if response.response.Body, err = tools.CompressionDecode(obj.ctx, response.response.Body, response.ContentEncoding()); err != nil { - return + if unCompressionBody != nil { + response.response.Body = unCompressionBody } } return