@azure-rest/core-client
Advanced tools
Comparing version 1.0.0-alpha.20210527.3 to 1.0.0-alpha.20210610.1
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { __awaiter } from "tslib"; | ||
/** | ||
@@ -11,7 +10,5 @@ * The programmatic identifier of the bearerTokenAuthenticationPolicy. | ||
name: keyCredentialAuthenticationPolicyName, | ||
sendRequest(request, next) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
request.headers.set(apiKeyHeaderName, credential.key); | ||
return next(request); | ||
}); | ||
async sendRequest(request, next) { | ||
request.headers.set(apiKeyHeaderName, credential.key); | ||
return next(request); | ||
}, | ||
@@ -18,0 +15,0 @@ }; |
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
import { __awaiter } from "tslib"; | ||
import { createHttpHeaders, createPipelineRequest, } from "@azure/core-rest-pipeline"; | ||
@@ -14,33 +13,31 @@ import { getCachedDefaultHttpsClient } from "./clientHelpers"; | ||
*/ | ||
export function sendRequest(method, url, pipeline, options = {}) { | ||
export async function sendRequest(method, url, pipeline, options = {}) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; | ||
const headers = createHttpHeaders(Object.assign(Object.assign({ accept: (_a = options.accept) !== null && _a !== void 0 ? _a : "application/json" }, (body !== undefined && { | ||
"content-type": (_b = options.contentType) !== null && _b !== void 0 ? _b : getContentType(options.body), | ||
})), (options.headers ? options.headers : {}))); | ||
const request = createPipelineRequest({ | ||
url, | ||
method, | ||
body, | ||
headers, | ||
allowInsecureConnection: options.allowInsecureConnection, | ||
}); | ||
const result = yield pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = result.headers.toJSON(); | ||
let parsedBody = undefined; | ||
try { | ||
parsedBody = result.bodyAsText ? JSON.parse(result.bodyAsText) : undefined; | ||
} | ||
catch (_c) { | ||
parsedBody = undefined; | ||
} | ||
return { | ||
request, | ||
headers: rawHeaders, | ||
status: `${result.status}`, | ||
body: parsedBody, | ||
}; | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; | ||
const headers = createHttpHeaders(Object.assign(Object.assign({ accept: (_a = options.accept) !== null && _a !== void 0 ? _a : "application/json" }, (body !== undefined && { | ||
"content-type": (_b = options.contentType) !== null && _b !== void 0 ? _b : getContentType(options.body), | ||
})), (options.headers ? options.headers : {}))); | ||
const request = createPipelineRequest({ | ||
url, | ||
method, | ||
body, | ||
headers, | ||
allowInsecureConnection: options.allowInsecureConnection, | ||
}); | ||
const result = await pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = result.headers.toJSON(); | ||
let parsedBody = undefined; | ||
try { | ||
parsedBody = result.bodyAsText ? JSON.parse(result.bodyAsText) : undefined; | ||
} | ||
catch (_c) { | ||
parsedBody = undefined; | ||
} | ||
return { | ||
request, | ||
headers: rawHeaders, | ||
status: `${result.status}`, | ||
body: parsedBody, | ||
}; | ||
} | ||
@@ -47,0 +44,0 @@ /** |
@@ -7,6 +7,6 @@ 'use strict'; | ||
var coreAuth = require('@azure/core-auth'); | ||
var tslib = require('tslib'); | ||
var url = require('url'); | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
/** | ||
@@ -19,7 +19,5 @@ * The programmatic identifier of the bearerTokenAuthenticationPolicy. | ||
name: keyCredentialAuthenticationPolicyName, | ||
sendRequest(request, next) { | ||
return tslib.__awaiter(this, void 0, void 0, function* () { | ||
request.headers.set(apiKeyHeaderName, credential.key); | ||
return next(request); | ||
}); | ||
async sendRequest(request, next) { | ||
request.headers.set(apiKeyHeaderName, credential.key); | ||
return next(request); | ||
}, | ||
@@ -124,33 +122,31 @@ }; | ||
*/ | ||
function sendRequest(method, url, pipeline, options = {}) { | ||
async function sendRequest(method, url, pipeline, options = {}) { | ||
var _a, _b; | ||
return tslib.__awaiter(this, void 0, void 0, function* () { | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; | ||
const headers = coreRestPipeline.createHttpHeaders(Object.assign(Object.assign({ accept: (_a = options.accept) !== null && _a !== void 0 ? _a : "application/json" }, (body !== undefined && { | ||
"content-type": (_b = options.contentType) !== null && _b !== void 0 ? _b : getContentType(options.body), | ||
})), (options.headers ? options.headers : {}))); | ||
const request = coreRestPipeline.createPipelineRequest({ | ||
url, | ||
method, | ||
body, | ||
headers, | ||
allowInsecureConnection: options.allowInsecureConnection, | ||
}); | ||
const result = yield pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = result.headers.toJSON(); | ||
let parsedBody = undefined; | ||
try { | ||
parsedBody = result.bodyAsText ? JSON.parse(result.bodyAsText) : undefined; | ||
} | ||
catch (_c) { | ||
parsedBody = undefined; | ||
} | ||
return { | ||
request, | ||
headers: rawHeaders, | ||
status: `${result.status}`, | ||
body: parsedBody, | ||
}; | ||
const httpClient = getCachedDefaultHttpsClient(); | ||
const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; | ||
const headers = coreRestPipeline.createHttpHeaders(Object.assign(Object.assign({ accept: (_a = options.accept) !== null && _a !== void 0 ? _a : "application/json" }, (body !== undefined && { | ||
"content-type": (_b = options.contentType) !== null && _b !== void 0 ? _b : getContentType(options.body), | ||
})), (options.headers ? options.headers : {}))); | ||
const request = coreRestPipeline.createPipelineRequest({ | ||
url, | ||
method, | ||
body, | ||
headers, | ||
allowInsecureConnection: options.allowInsecureConnection, | ||
}); | ||
const result = await pipeline.sendRequest(httpClient, request); | ||
const rawHeaders = result.headers.toJSON(); | ||
let parsedBody = undefined; | ||
try { | ||
parsedBody = result.bodyAsText ? JSON.parse(result.bodyAsText) : undefined; | ||
} | ||
catch (_c) { | ||
parsedBody = undefined; | ||
} | ||
return { | ||
request, | ||
headers: rawHeaders, | ||
status: `${result.status}`, | ||
body: parsedBody, | ||
}; | ||
} | ||
@@ -157,0 +153,0 @@ /** |
{ | ||
"name": "@azure-rest/core-client", | ||
"version": "1.0.0-alpha.20210527.3", | ||
"version": "1.0.0-alpha.20210610.1", | ||
"description": "Core library for interfacing with AutoRest rest level generated code", | ||
@@ -11,3 +11,3 @@ "sdk-type": "client", | ||
}, | ||
"types": "types/src/latest/core-client.d.ts", | ||
"types": "types/src/latest/core-client-rest.d.ts", | ||
"scripts": { | ||
@@ -44,3 +44,3 @@ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", | ||
"dist-esm/src/", | ||
"types/src/latest/core-client.d.ts", | ||
"types/src/latest/core-client-rest.d.ts", | ||
"README.md", | ||
@@ -62,3 +62,3 @@ "LICENSE" | ||
}, | ||
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core-rest/core-client/", | ||
"homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core/core-client-rest/", | ||
"sideEffects": false, | ||
@@ -65,0 +65,0 @@ "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
1
83940
713