Skip to content

Commit 17c99af

Browse files
committed
remove unnecessary gzip decoding
1 parent a6bedf2 commit 17c99af

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

graphql.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package graphql
22

33
import (
44
"bytes"
5-
"compress/gzip"
65
"context"
76
"encoding/json"
87
"errors"
@@ -214,7 +213,6 @@ func (c *Client) doHttpRequest(ctx context.Context, body io.ReadSeeker) *rawGrap
214213
}
215214

216215
request.Header.Add("Content-Type", "application/json")
217-
request.Header.Add("Accept-Encoding", "gzip")
218216

219217
if c.requestModifier != nil {
220218
c.requestModifier(request)
@@ -338,28 +336,6 @@ func (c *Client) decodeRawGraphQLResponse(
338336
) *rawGraphQLResult {
339337
var r io.Reader = resp.Body
340338

341-
if resp.Header.Get("Content-Encoding") == "gzip" {
342-
gr, err := gzip.NewReader(r)
343-
if err != nil {
344-
return &rawGraphQLResult{
345-
request: req,
346-
requestBody: reqBody,
347-
Errors: Errors{
348-
newError(
349-
ErrJsonDecode,
350-
fmt.Errorf("problem trying to create gzip reader: %w", err),
351-
),
352-
},
353-
}
354-
}
355-
356-
defer func() {
357-
_ = gr.Close()
358-
}()
359-
360-
r = gr
361-
}
362-
363339
// copy the response reader for debugging
364340
var respReader *bytes.Reader
365341

graphql_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,10 +985,10 @@ func TestClient_Query_Compression(t *testing.T) {
985985
gw.Close()
986986
})
987987

988-
client := graphql.NewClient(
989-
"/graphql",
990-
&http.Client{Transport: localRoundTripper{handler: mux}},
991-
)
988+
server := httptest.NewServer(mux)
989+
defer server.Close()
990+
991+
client := graphql.NewClient(server.URL+"/graphql", http.DefaultClient)
992992

993993
var q struct {
994994
User struct {

0 commit comments

Comments
 (0)