Skip to content

Commit 5d96175

Browse files
authored
[core-rest-pipeline][core-client] Replace "HTTPS" with "HTTP" in interface names (Azure#14142)
Despite no service being allowed to ship a non-TLS encrypted endpoint, it turns out there are cases (such as the AutoRest test server) where we want Core to be able to make insecure connections. The work to support such connections will be added in a later PR (to avoid risk) but this PR renames all public interfaces to make it clear that connections do not need to be TLS encrypted.
1 parent 426d0db commit 5d96175

24 files changed

+138
-144
lines changed

sdk/core/core-client/review/core-client.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
```ts
66

77
import { AbortSignalLike } from '@azure/abort-controller';
8+
import { HttpClient } from '@azure/core-rest-pipeline';
89
import { HttpMethods } from '@azure/core-rest-pipeline';
9-
import { HttpsClient } from '@azure/core-rest-pipeline';
1010
import { InternalPipelineOptions } from '@azure/core-rest-pipeline';
1111
import { OperationTracingOptions } from '@azure/core-tracing';
1212
import { Pipeline } from '@azure/core-rest-pipeline';
@@ -37,7 +37,7 @@ export interface BaseMapper {
3737

3838
// @public
3939
export interface CommonClientOptions extends PipelineOptions {
40-
httpsClient?: HttpsClient;
40+
httpClient?: HttpClient;
4141
}
4242

4343
// @public (undocumented)
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT license.
33

4-
import { HttpsClient, createDefaultHttpsClient } from "@azure/core-rest-pipeline";
4+
import { HttpClient, createDefaultHttpClient } from "@azure/core-rest-pipeline";
55

6-
let cachedHttpsClient: HttpsClient | undefined;
6+
let cachedHttpClient: HttpClient | undefined;
77

8-
export function getCachedDefaultHttpsClient(): HttpsClient {
9-
if (!cachedHttpsClient) {
10-
cachedHttpsClient = createDefaultHttpsClient();
8+
export function getCachedDefaultHttpClient(): HttpClient {
9+
if (!cachedHttpClient) {
10+
cachedHttpClient = createDefaultHttpClient();
1111
}
1212

13-
return cachedHttpsClient;
13+
return cachedHttpClient;
1414
}

sdk/core/core-client/src/interfaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
TransferProgressEvent,
1010
PipelineRequest,
1111
PipelineOptions,
12-
HttpsClient
12+
HttpClient
1313
} from "@azure/core-rest-pipeline";
1414

1515
/**
@@ -547,5 +547,5 @@ export interface CommonClientOptions extends PipelineOptions {
547547
/**
548548
* The HttpClient that will be used to send HTTP requests.
549549
*/
550-
httpsClient?: HttpsClient;
550+
httpClient?: HttpClient;
551551
}

sdk/core/core-client/src/serviceClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import { TokenCredential } from "@azure/core-auth";
55
import {
6-
HttpsClient,
6+
HttpClient,
77
PipelineRequest,
88
PipelineResponse,
99
Pipeline,
@@ -19,7 +19,7 @@ import { getStreamingResponseStatusCodes } from "./interfaceHelpers";
1919
import { getRequestUrl } from "./urlHelpers";
2020
import { flattenResponse } from "./utils";
2121
import { URL } from "./url";
22-
import { getCachedDefaultHttpsClient } from "./httpClientCache";
22+
import { getCachedDefaultHttpClient } from "./httpClientCache";
2323
import { getOperationRequestInfo } from "./operationHelpers";
2424
import { createClientPipeline } from "./pipeline";
2525

@@ -70,7 +70,7 @@ export class ServiceClient {
7070
/**
7171
* The HTTP client that will be used to send requests.
7272
*/
73-
private readonly _httpsClient: HttpsClient;
73+
private readonly _httpClient: HttpClient;
7474

7575
/**
7676
* The pipeline used by this client to make requests
@@ -85,7 +85,7 @@ export class ServiceClient {
8585
constructor(options: ServiceClientOptions = {}) {
8686
this._requestContentType = options.requestContentType;
8787
this._baseUri = options.baseUri;
88-
this._httpsClient = options.httpsClient || getCachedDefaultHttpsClient();
88+
this._httpClient = options.httpClient || getCachedDefaultHttpClient();
8989

9090
this.pipeline = options.pipeline || createDefaultPipeline(options);
9191
}
@@ -94,7 +94,7 @@ export class ServiceClient {
9494
* Send the provided httpRequest.
9595
*/
9696
async sendRequest(request: PipelineRequest): Promise<PipelineResponse> {
97-
return this.pipeline.sendRequest(this._httpsClient, request);
97+
return this.pipeline.sendRequest(this._httpClient, request);
9898
}
9999

100100
/**

sdk/core/core-client/test/serviceClient.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
import {
2121
createHttpHeaders,
2222
createEmptyPipeline,
23-
HttpsClient,
23+
HttpClient,
2424
createPipelineRequest
2525
} from "@azure/core-rest-pipeline";
2626

@@ -30,7 +30,7 @@ import {
3030
} from "../src/operationHelpers";
3131
import { deserializationPolicy } from "../src/deserializationPolicy";
3232
import { TokenCredential } from "@azure/core-auth";
33-
import { getCachedDefaultHttpsClient } from "../src/httpClientCache";
33+
import { getCachedDefaultHttpClient } from "../src/httpClientCache";
3434

3535
describe("ServiceClient", function() {
3636
describe("Auth scopes", () => {
@@ -85,7 +85,7 @@ describe("ServiceClient", function() {
8585
try {
8686
let request: OperationRequest;
8787
const client = new ServiceClient({
88-
httpsClient: {
88+
httpClient: {
8989
sendRequest: (req) => {
9090
request = req;
9191
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });
@@ -111,7 +111,7 @@ describe("ServiceClient", function() {
111111
try {
112112
let request: OperationRequest;
113113
const client = new ServiceClient({
114-
httpsClient: {
114+
httpClient: {
115115
sendRequest: (req) => {
116116
request = req;
117117
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });
@@ -141,7 +141,7 @@ describe("ServiceClient", function() {
141141

142142
let request: OperationRequest;
143143
const client = new ServiceClient({
144-
httpsClient: {
144+
httpClient: {
145145
sendRequest: (req) => {
146146
request = req;
147147
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });
@@ -168,7 +168,7 @@ describe("ServiceClient", function() {
168168

169169
let request: OperationRequest;
170170
const client = new ServiceClient({
171-
httpsClient: {
171+
httpClient: {
172172
sendRequest: (req) => {
173173
request = req;
174174
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });
@@ -196,7 +196,7 @@ describe("ServiceClient", function() {
196196
const pipeline = createEmptyPipeline();
197197
pipeline.addPolicy(serializationPolicy(), { phase: "Serialize" });
198198
const client = new ServiceClient({
199-
httpsClient: {
199+
httpClient: {
200200
sendRequest: (req) => {
201201
request = req;
202202
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });
@@ -256,7 +256,7 @@ describe("ServiceClient", function() {
256256
it("should call rawResponseCallback with the full response", async function() {
257257
let request: OperationRequest;
258258
const client = new ServiceClient({
259-
httpsClient: {
259+
httpClient: {
260260
sendRequest: (req) => {
261261
request = req;
262262
return Promise.resolve({
@@ -329,7 +329,7 @@ describe("ServiceClient", function() {
329329

330330
it("should deserialize response bodies", async function() {
331331
let request: OperationRequest;
332-
const httpsClient: HttpsClient = {
332+
const httpClient: HttpClient = {
333333
sendRequest: (req) => {
334334
request = req;
335335
return Promise.resolve({
@@ -344,7 +344,7 @@ describe("ServiceClient", function() {
344344
const pipeline = createEmptyPipeline();
345345
pipeline.addPolicy(deserializationPolicy());
346346
const client1 = new ServiceClient({
347-
httpsClient,
347+
httpClient,
348348
pipeline
349349
});
350350

@@ -791,7 +791,7 @@ describe("ServiceClient", function() {
791791
const operationInfo = getOperationRequestInfo(request);
792792
operationInfo.operationSpec = operationSpec;
793793

794-
const httpsClient: HttpsClient = {
794+
const httpClient: HttpClient = {
795795
sendRequest: (req) => {
796796
request = req;
797797
return Promise.resolve({
@@ -808,7 +808,7 @@ describe("ServiceClient", function() {
808808
const pipeline = createEmptyPipeline();
809809
pipeline.addPolicy(deserializationPolicy());
810810
const client = new ServiceClient({
811-
httpsClient,
811+
httpClient,
812812
pipeline
813813
});
814814

@@ -871,7 +871,7 @@ describe("ServiceClient", function() {
871871
const operationInfo = getOperationRequestInfo(request);
872872
operationInfo.operationSpec = operationSpec;
873873

874-
const httpsClient: HttpsClient = {
874+
const httpClient: HttpClient = {
875875
sendRequest: (req) => {
876876
request = req;
877877
return Promise.resolve({
@@ -888,7 +888,7 @@ describe("ServiceClient", function() {
888888
const pipeline = createEmptyPipeline();
889889
pipeline.addPolicy(deserializationPolicy());
890890
const client = new ServiceClient({
891-
httpsClient,
891+
httpClient,
892892
pipeline
893893
});
894894

@@ -903,7 +903,7 @@ describe("ServiceClient", function() {
903903

904904
it("should re-use the common instance of DefaultHttpClient", function() {
905905
const client = new ServiceClient();
906-
assert.strictEqual((client as any)._httpsClient, getCachedDefaultHttpsClient());
906+
assert.strictEqual((client as any)._httpClient, getCachedDefaultHttpClient());
907907
});
908908
});
909909

@@ -915,7 +915,7 @@ async function testSendOperationRequest(
915915
): Promise<void> {
916916
let request: OperationRequest;
917917
const client = new ServiceClient({
918-
httpsClient: {
918+
httpClient: {
919919
sendRequest: (req) => {
920920
request = req;
921921
return Promise.resolve({ request, status: 200, headers: createHttpHeaders() });

sdk/core/core-rest-pipeline/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.0.0-beta.2 (Unreleased)
44

5+
- Renamed interfaces with `HTTPS` in the name to have `HTTP` instead.
56
- Changed from exposing `DefaultHttpsClient` as a class directly, to providing `createDefaultHttpsClient()` to instantiate the appropriate runtime class.
67
- Fix an issue when passing in proxy hosts. [PR 13911](https://github.com/Azure/azure-sdk-for-js/pull/13911)
78
- Package rename to `core-rest-pipeline` to better reflect its purpose.

sdk/core/core-rest-pipeline/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,20 @@ A `SendRequest` method is a method that given a `PipelineRequest` can asynchrono
3030
export type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse>;
3131
```
3232

33-
### HttpsClient
33+
### HttpClient
3434

35-
An `HttpsClient` is any object that satisfies the following interface to implement a `SendRequest` method:
35+
An `HttpClient` is any object that satisfies the following interface to implement a `SendRequest` method:
3636

3737
```ts
38-
export interface HttpsClient {
38+
export interface HttpClient {
3939
/**
4040
* The method that makes the request and returns a response.
4141
*/
4242
sendRequest: SendRequest;
4343
}
4444
```
4545

46-
`HttpsClient`s are expected to actually make the HTTP request to a server endpoint, using some platform-specific mechanism for doing so.
46+
`HttpClient`s are expected to actually make the HTTP request to a server endpoint, using some platform-specific mechanism for doing so.
4747

4848
### Pipeline Policies
4949

@@ -64,7 +64,7 @@ export interface PipelinePolicy {
6464
}
6565
```
6666

67-
It is similar in shape to `HttpsClient`, but includes a policy name as well as a slightly modified `SendRequest` signature that allows it to conditionally call the next policy in the pipeline.
67+
It is similar in shape to `HttpClient`, but includes a policy name as well as a slightly modified `SendRequest` signature that allows it to conditionally call the next policy in the pipeline.
6868

6969
One can view the role of policies as that of `middleware`, a concept that is familiar to NodeJS developers who have worked with frameworks such as [Express](https://expressjs.com/).
7070

@@ -99,13 +99,13 @@ A `Pipeline` satisfies the following interface:
9999
export interface Pipeline {
100100
addPolicy(policy: PipelinePolicy, options?: AddPolicyOptions): void;
101101
removePolicy(options: { name?: string; phase?: PipelinePhase }): PipelinePolicy[];
102-
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>;
102+
sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>;
103103
getOrderedPolicies(): PipelinePolicy[];
104104
clone(): Pipeline;
105105
}
106106
```
107107

108-
As you can see it allows for policies to be added or removed and it is loosely coupled with `HttpsClient` to perform the real request to the server endpoint.
108+
As you can see it allows for policies to be added or removed and it is loosely coupled with `HttpClient` to perform the real request to the server endpoint.
109109

110110
One important concept for `Pipeline`s is that they group policies into ordered phases:
111111

sdk/core/core-rest-pipeline/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "@azure/core-rest-pipeline",
33
"version": "1.0.0-beta.2",
4-
"description": "Isomorphic client library for making HTTPS requests in node.js and browser.",
4+
"description": "Isomorphic client library for making HTTP requests in node.js and browser.",
55
"sdk-type": "client",
66
"main": "dist/index.js",
77
"module": "dist-esm/src/index.js",
88
"browser": {
9-
"./dist-esm/src/defaultHttpsClient.js": "./dist-esm/src/defaultHttpsClient.browser.js",
9+
"./dist-esm/src/defaultHttpClient.js": "./dist-esm/src/defaultHttpClient.browser.js",
1010
"./dist-esm/src/policies/decompressResponsePolicy.js": "./dist-esm/src/policies/decompressResponsePolicy.browser.js",
1111
"./dist-esm/src/policies/formDataPolicy.js": "./dist-esm/src/policies/formDataPolicy.browser.js",
1212
"./dist-esm/src/policies/proxyPolicy.js": "./dist-esm/src/policies/proxyPolicy.browser.js",

sdk/core/core-rest-pipeline/review/core-rest-pipeline.api.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface BearerTokenAuthenticationPolicyOptions {
3030
}
3131

3232
// @public
33-
export function createDefaultHttpsClient(): HttpsClient;
33+
export function createDefaultHttpClient(): HttpClient;
3434

3535
// @public
3636
export function createEmptyPipeline(): Pipeline;
@@ -80,6 +80,11 @@ export type FormDataValue = string | Blob;
8080
// @public
8181
export function getDefaultProxySettings(proxyUrl?: string): ProxySettings | undefined;
8282

83+
// @public
84+
export interface HttpClient {
85+
sendRequest: SendRequest;
86+
}
87+
8388
// @public
8489
export interface HttpHeaders extends Iterable<[string, string]> {
8590
delete(name: string): void;
@@ -92,11 +97,6 @@ export interface HttpHeaders extends Iterable<[string, string]> {
9297
// @public
9398
export type HttpMethods = "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE";
9499

95-
// @public
96-
export interface HttpsClient {
97-
sendRequest: SendRequest;
98-
}
99-
100100
// @public
101101
export interface InternalPipelineOptions extends PipelineOptions {
102102
loggingOptions?: LogPolicyOptions;
@@ -130,7 +130,7 @@ export interface Pipeline {
130130
name?: string;
131131
phase?: PipelinePhase;
132132
}): PipelinePolicy[];
133-
sendRequest(httpsClient: HttpsClient, request: PipelineRequest): Promise<PipelineResponse>;
133+
sendRequest(httpClient: HttpClient, request: PipelineRequest): Promise<PipelineResponse>;
134134
}
135135

136136
// @public
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
4+
import { HttpClient } from "./interfaces";
5+
import { createXhrHttpClient } from "./xhrHttpClient";
6+
7+
/**
8+
* Create the correct HttpClient for the current environment.
9+
*/
10+
export function createDefaultHttpClient(): HttpClient {
11+
return createXhrHttpClient();
12+
}

0 commit comments

Comments
 (0)