Merge branch 'fix_gzip_compression' of https://github.com/birdypme/pulumi into birdypme-fix_gzip_compression
This commit is contained in:
commit
32f13fabfa
|
@ -9,6 +9,10 @@ CHANGELOG
|
|||
- Correctly validate project names during 'pulumi new'
|
||||
[#5504](https://github.com/pulumi/pulumi/pull/5504)
|
||||
|
||||
- Fixing gzip compression for alternative backends.
|
||||
[#5484](https://github.com/pulumi/pulumi/pull/5484)
|
||||
|
||||
|
||||
## 2.11.2 (2020-10-01)
|
||||
|
||||
- feat(autoapi): expose EnvVars LocalWorkspaceOption to set in ctor
|
||||
|
|
|
@ -137,9 +137,11 @@ func pulumiAPICall(ctx context.Context, d diag.Sink, cloudAPI, method, path stri
|
|||
return "", nil, errors.Wrapf(err, "compressing payload")
|
||||
}
|
||||
|
||||
// gzip.Writer will not actually write anything unless it is flushed.
|
||||
if err := writer.Flush(); err != nil {
|
||||
return "", nil, errors.Wrapf(err, "flushing compressed payload")
|
||||
// gzip.Writer will not actually write anything unless it is flushed,
|
||||
// and it will not actually write the GZip footer unless it is closed. (Close also flushes)
|
||||
// Without this, the compressed bytes do not decompress properly e.g. in python.
|
||||
if err := writer.Close(); err != nil {
|
||||
return "", nil, errors.Wrapf(err, "closing compressed payload")
|
||||
}
|
||||
|
||||
logging.V(apiRequestDetailLogLevel).Infof("gzip compression ratio: %f, original size: %d bytes",
|
||||
|
@ -331,7 +333,9 @@ func readBody(resp *http.Response) ([]byte, error) {
|
|||
case "gzip":
|
||||
logging.V(apiRequestDetailLogLevel).Infoln("decompressing gzipped response from service")
|
||||
reader, err := gzip.NewReader(resp.Body)
|
||||
defer contract.IgnoreClose(reader)
|
||||
if reader != nil {
|
||||
defer contract.IgnoreClose(reader)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "reading gzip-compressed body")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue