@@ -16,6 +16,7 @@ import (
1616 ioaux "github.com/jig/teereadcloser"
1717 "github.com/kballard/go-shellquote"
1818 "github.com/mattn/go-isatty"
19+
1920 "github.com/sourcegraph/src-cli/internal/version"
2021)
2122
@@ -25,16 +26,9 @@ type Client interface {
2526 // variables.
2627 NewQuery (query string ) Request
2728
28- // NewRequest creates a GraphQL request.
29+ // NewRequest creates a GraphQL request with gzip compression turned on .
2930 NewRequest (query string , vars map [string ]interface {}) Request
3031
31- // NewGzippedRequest creates a GraphQL request with gzip compression turned on.
32- NewGzippedRequest (query string , vars map [string ]interface {}) Request
33-
34- // NewGzippedQuery is a convenience wrapper around NewQuery with gzip
35- // compression turned on.
36- NewGzippedQuery (query string ) Request
37-
3832 // NewHTTPRequest creates an http.Request for the Sourcegraph API.
3933 //
4034 // path is joined against the API route. For example on Sourcegraph.com this
@@ -72,7 +66,6 @@ type request struct {
7266 client * client
7367 query string
7468 vars map [string ]interface {}
75- gzip bool
7669}
7770
7871// ClientOpts encapsulates the options given to NewClient.
@@ -132,19 +125,6 @@ func (c *client) NewRequest(query string, vars map[string]interface{}) Request {
132125 }
133126}
134127
135- func (c * client ) NewGzippedRequest (query string , vars map [string ]interface {}) Request {
136- return & request {
137- client : c ,
138- query : query ,
139- vars : vars ,
140- gzip : true ,
141- }
142- }
143-
144- func (c * client ) NewGzippedQuery (query string ) Request {
145- return c .NewGzippedRequest (query , nil )
146- }
147-
148128func (c * client ) Do (req * http.Request ) (* http.Response , error ) {
149129 return c .httpClient .Do (req )
150130}
@@ -216,19 +196,16 @@ func (r *request) do(ctx context.Context, result interface{}) (bool, error) {
216196 }
217197
218198 var bufBody io.Reader = bytes .NewBuffer (reqBody )
219- if r .gzip {
220- bufBody = gzipReader (bufBody )
221- }
199+ bufBody = gzipReader (bufBody )
222200
223201 // Create the HTTP request.
224202 req , err := r .client .NewHTTPRequest (ctx , "POST" , ".api/graphql" , bufBody )
225203 if err != nil {
226204 return false , err
227205 }
228206
229- if r .gzip {
230- req .Header .Set ("Content-Encoding" , "gzip" )
231- }
207+ // Use gzip compression.
208+ req .Header .Set ("Content-Encoding" , "gzip" )
232209
233210 // Perform the request.
234211 resp , err := r .client .httpClient .Do (req )
0 commit comments