Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 2 additions & 1 deletion sdk/core/core-client-rest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Release History

## 1.1.4 (Unreleased)
## 1.1.4 (2023-07-07)

### Features Added

- Add `timeout`, `onUploadProgress`, `onDownloadProgress`, `abortSignal`, `tracingOptions`, `onResponse` in the `RequestParameters` for better RLC user experience.
- Add `OperationOptions` for better modular user experience.
- Correctly handle `allowInsecureConnection` handling when `undefined` is passed in `RequestParameters`. See https://github.com/Azure/autorest.typescript/issues/1916 for details.

## 1.1.3 (2023-05-04)

Expand Down
7 changes: 4 additions & 3 deletions sdk/core/core-client-rest/src/getClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,14 @@ function buildOperation(
allowInsecureConnection?: boolean,
httpClient?: HttpClient
): StreamableMethod {
allowInsecureConnection = options.allowInsecureConnection ?? allowInsecureConnection;
return {
then: function (onFulfilled, onrejected) {
return sendRequest(
method,
url,
pipeline,
{ allowInsecureConnection, ...options },
{ ...options, allowInsecureConnection },
httpClient
).then(onFulfilled, onrejected);
},
Expand All @@ -177,7 +178,7 @@ function buildOperation(
method,
url,
pipeline,
{ allowInsecureConnection, ...options },
{ ...options, allowInsecureConnection },
httpClient
);
},
Expand All @@ -186,7 +187,7 @@ function buildOperation(
method,
url,
pipeline,
{ allowInsecureConnection, ...options },
{ ...options, allowInsecureConnection },
httpClient
);
},
Expand Down
37 changes: 37 additions & 0 deletions sdk/core/core-client-rest/test/getClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { getCachedDefaultHttpsClient } from "../src/clientHelpers";
import { getClient } from "../src/getClient";
import sinon from "sinon";
import {
HttpClient,
PipelinePolicy,
PipelineRequest,
PipelineResponse,
Expand Down Expand Up @@ -200,4 +201,40 @@ describe("getClient", () => {
assert.isTrue(policies.indexOf(policy2) < policies.indexOf(retryPolicy));
assert.isTrue(policies.indexOf(retryPolicy) < policies.indexOf(policy1));
});

it("should use the client setting for `allowInsecureConnection` when the request setting is undefined", async () => {
const fakeHttpClient: HttpClient = {
sendRequest: async (request) => {
assert.isTrue(request.allowInsecureConnection);
return { headers: createHttpHeaders(), status: 200, request };
},
};

const client = getClient("https://example.org", {
allowInsecureConnection: true,
httpClient: fakeHttpClient,
});

await client.pathUnchecked("/foo").get({
allowInsecureConnection: undefined,
});
});

it("should not use the client setting for `allowInsecureConnection` when the request setting is false", async () => {
const fakeHttpClient: HttpClient = {
sendRequest: async (request) => {
assert.isFalse(request.allowInsecureConnection);
return { headers: createHttpHeaders(), status: 200, request };
},
};

const client = getClient("https://example.org", {
allowInsecureConnection: true,
httpClient: fakeHttpClient,
});

await client.pathUnchecked("/foo").get({
allowInsecureConnection: false,
});
});
});