Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core-https] Fix decoding of gzip responses #13605

Merged
2 commits merged into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/core/core-https/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

export const SDK_VERSION: string = "1.0.0-preview.1";
export const SDK_VERSION: string = "1.0.0-beta.1";
11 changes: 3 additions & 8 deletions sdk/core/core-https/src/nodeHttpsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class NodeHttpsClient implements HttpsClient {
request
};

let responseStream = getResponseStream(res, headers, shouldDecompress);
let responseStream = shouldDecompress ? getDecodedResponseStream(res, headers) : res;

const onDownloadProgress = request.onDownloadProgress;
if (onDownloadProgress) {
Expand Down Expand Up @@ -249,15 +249,10 @@ function getResponseHeaders(res: IncomingMessage): HttpHeaders {
return headers;
}

function getResponseStream(
function getDecodedResponseStream(
stream: IncomingMessage,
headers: HttpHeaders,
skipDecompressResponse = false
headers: HttpHeaders
): NodeJS.ReadableStream {
if (skipDecompressResponse) {
return stream;
}

const contentEncoding = headers.get("Content-Encoding");
if (contentEncoding === "gzip") {
const unzip = zlib.createGunzip();
Expand Down
7 changes: 0 additions & 7 deletions sdk/core/core-https/src/pipelineRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ export interface PipelineRequestOptions {
*/
keepAlive?: boolean;

/**
* Disable automatic decompression based on Accept-Encoding header (Node only)
*/
skipDecompressResponse?: boolean;

/**
* Used to abort the request later.
*/
Expand Down Expand Up @@ -113,7 +108,6 @@ class PipelineRequestImpl implements PipelineRequest {
public streamResponseStatusCodes?: Set<number>;
public proxySettings?: ProxySettings;
public keepAlive: boolean;
public skipDecompressResponse: boolean;
public abortSignal?: AbortSignalLike;
public requestId: string;
public spanOptions?: SpanOptions;
Expand All @@ -129,7 +123,6 @@ class PipelineRequestImpl implements PipelineRequest {
this.formData = options.formData;
this.keepAlive = options.keepAlive ?? true;
this.proxySettings = options.proxySettings;
this.skipDecompressResponse = options.skipDecompressResponse ?? false;
this.streamResponseStatusCodes = options.streamResponseStatusCodes;
this.withCredentials = options.withCredentials ?? false;
this.abortSignal = options.abortSignal;
Expand Down