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-client] expose allowInsecureConection #14967

Merged
merged 2 commits into from
Apr 22, 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
1 change: 1 addition & 0 deletions sdk/core/core-client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 1.1.1 (Unreleased)

- Expose `allowInsecureConnection` in `ServiceClientOptions` and `OperationRequestOptions` to allow operation requests to HTTP endpoints

## 1.1.0 (2021-03-30)

Expand Down
2 changes: 2 additions & 0 deletions sdk/core/core-client/review/core-client.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export interface OperationRequestInfo {

// @public
export interface OperationRequestOptions {
allowInsecureConnection?: boolean;
customHeaders?: {
[key: string]: string;
};
Expand Down Expand Up @@ -350,6 +351,7 @@ export class ServiceClient {

// @public
export interface ServiceClientOptions extends CommonClientOptions {
allowInsecureConnection?: boolean;
baseUri?: string;
credential?: TokenCredential;
credentialScopes?: string | string[];
Expand Down
6 changes: 6 additions & 0 deletions sdk/core/core-client/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ export interface OperationRequestOptions {
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;

/**
* Whether or not the HttpOperationResponse should be deserialized. If this is undefined, then the
* HttpOperationResponse should be deserialized.
*/
shouldDeserialize?: boolean | ((response: PipelineResponse) => boolean);

/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions sdk/core/core-client/src/serviceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ export interface ServiceClientOptions extends CommonClientOptions {
* A customized pipeline to use, otherwise a default one will be created.
*/
pipeline?: Pipeline;
/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
}

/**
Expand All @@ -67,6 +71,11 @@ export class ServiceClient {
*/
private readonly _requestContentType?: string;

/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
private readonly _allowInsecureConnection?: boolean;

/**
* The HTTP client that will be used to send requests.
*/
Expand All @@ -85,6 +94,7 @@ export class ServiceClient {
constructor(options: ServiceClientOptions = {}) {
this._requestContentType = options.requestContentType;
this._baseUri = options.baseUri;
this._allowInsecureConnection = options.allowInsecureConnection;
this._httpClient = options.httpClient || getCachedDefaultHttpClient();

this.pipeline = options.pipeline || createDefaultPipeline(options);
Expand Down Expand Up @@ -152,6 +162,10 @@ export class ServiceClient {
if (requestOptions.shouldDeserialize !== undefined) {
operationInfo.shouldDeserialize = requestOptions.shouldDeserialize;
}

if (this._allowInsecureConnection || requestOptions.allowInsecureConnection) {
request.allowInsecureConnection = true;
}
}

if (options.abortSignal) {
Expand Down