Skip to content

Commit 043fb46

Browse files
authored
Merge pull request #797 from actions/yacaovsnc/update-dependency
Include changes in typespec/ts-http-runtime 0.3.5
2 parents e454baa + 634250c commit 043fb46

File tree

4 files changed

+206
-166
lines changed

4 files changed

+206
-166
lines changed

dist/merge/index.js

Lines changed: 100 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -88021,13 +88021,13 @@ class Sanitizer {
8802188021
message: value.message,
8802288022
};
8802388023
}
88024-
if (key === "headers") {
88024+
if (key === "headers" && isObject(value)) {
8802588025
return this.sanitizeHeaders(value);
8802688026
}
88027-
else if (key === "url") {
88027+
else if (key === "url" && typeof value === "string") {
8802888028
return this.sanitizeUrl(value);
8802988029
}
88030-
else if (key === "query") {
88030+
else if (key === "query" && isObject(value)) {
8803188031
return this.sanitizeQuery(value);
8803288032
}
8803388033
else if (key === "body") {
@@ -88598,6 +88598,68 @@ function logPolicy_logPolicy(options = {}) {
8859888598
};
8859988599
}
8860088600
//# sourceMappingURL=logPolicy.js.map
88601+
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/policies/redirectPolicy.js
88602+
// Copyright (c) Microsoft Corporation.
88603+
// Licensed under the MIT License.
88604+
88605+
/**
88606+
* The programmatic identifier of the redirectPolicy.
88607+
*/
88608+
const redirectPolicyName = "redirectPolicy";
88609+
/**
88610+
* Methods that are allowed to follow redirects 301 and 302
88611+
*/
88612+
const allowedRedirect = ["GET", "HEAD"];
88613+
/**
88614+
* A policy to follow Location headers from the server in order
88615+
* to support server-side redirection.
88616+
* In the browser, this policy is not used.
88617+
* @param options - Options to control policy behavior.
88618+
*/
88619+
function redirectPolicy_redirectPolicy(options = {}) {
88620+
const { maxRetries = 20, allowCrossOriginRedirects = false } = options;
88621+
return {
88622+
name: redirectPolicyName,
88623+
async sendRequest(request, next) {
88624+
const response = await next(request);
88625+
return handleRedirect(next, response, maxRetries, allowCrossOriginRedirects);
88626+
},
88627+
};
88628+
}
88629+
async function handleRedirect(next, response, maxRetries, allowCrossOriginRedirects, currentRetries = 0) {
88630+
const { request, status, headers } = response;
88631+
const locationHeader = headers.get("location");
88632+
if (locationHeader &&
88633+
(status === 300 ||
88634+
(status === 301 && allowedRedirect.includes(request.method)) ||
88635+
(status === 302 && allowedRedirect.includes(request.method)) ||
88636+
(status === 303 && request.method === "POST") ||
88637+
status === 307) &&
88638+
currentRetries < maxRetries) {
88639+
const url = new URL(locationHeader, request.url);
88640+
// Only follow redirects to the same origin by default.
88641+
if (!allowCrossOriginRedirects) {
88642+
const originalUrl = new URL(request.url);
88643+
if (url.origin !== originalUrl.origin) {
88644+
log_logger.verbose(`Skipping cross-origin redirect from ${originalUrl.origin} to ${url.origin}.`);
88645+
return response;
88646+
}
88647+
}
88648+
request.url = url.toString();
88649+
// POST request with Status code 303 should be converted into a
88650+
// redirected GET request if the redirect url is present in the location header
88651+
if (status === 303) {
88652+
request.method = "GET";
88653+
request.headers.delete("Content-Length");
88654+
delete request.body;
88655+
}
88656+
request.headers.delete("Authorization");
88657+
const res = await next(request);
88658+
return handleRedirect(next, res, maxRetries, allowCrossOriginRedirects, currentRetries + 1);
88659+
}
88660+
return response;
88661+
}
88662+
//# sourceMappingURL=redirectPolicy.js.map
8860188663
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/util/userAgentPlatform.js
8860288664
// Copyright (c) Microsoft Corporation.
8860388665
// Licensed under the MIT License.
@@ -88615,15 +88677,14 @@ function getHeaderName() {
8861588677
async function userAgentPlatform_setPlatformSpecificData(map) {
8861688678
if (process && process.versions) {
8861788679
const osInfo = `${os.type()} ${os.release()}; ${os.arch()}`;
88618-
const versions = process.versions;
88619-
if (versions.bun) {
88620-
map.set("Bun", `${versions.bun} (${osInfo})`);
88680+
if (process.versions.bun) {
88681+
map.set("Bun", `${process.versions.bun} (${osInfo})`);
8862188682
}
88622-
else if (versions.deno) {
88623-
map.set("Deno", `${versions.deno} (${osInfo})`);
88683+
else if (process.versions.deno) {
88684+
map.set("Deno", `${process.versions.deno} (${osInfo})`);
8862488685
}
88625-
else if (versions.node) {
88626-
map.set("Node", `${versions.node} (${osInfo})`);
88686+
else if (process.versions.node) {
88687+
map.set("Node", `${process.versions.node} (${osInfo})`);
8862788688
}
8862888689
}
8862988690
}
@@ -88930,7 +88991,7 @@ function isSystemError(err) {
8893088991
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/constants.js
8893188992
// Copyright (c) Microsoft Corporation.
8893288993
// Licensed under the MIT License.
88933-
const constants_SDK_VERSION = "0.3.3";
88994+
const constants_SDK_VERSION = "0.3.5";
8893488995
const constants_DEFAULT_RETRY_POLICY_COUNT = 3;
8893588996
//# sourceMappingURL=constants.js.map
8893688997
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/policies/retryPolicy.js
@@ -88940,6 +89001,7 @@ const constants_DEFAULT_RETRY_POLICY_COUNT = 3;
8894089001

8894189002

8894289003

89004+
8894389005
const retryPolicyLogger = createClientLogger("ts-http-runtime retryPolicy");
8894489006
/**
8894589007
* The programmatic identifier of the retryPolicy.
@@ -88970,11 +89032,11 @@ function retryPolicy_retryPolicy(strategies, options = { maxRetries: constants_D
8897089032
// RestErrors are valid targets for the retry strategies.
8897189033
// If none of the retry strategies can work with them, they will be thrown later in this policy.
8897289034
// If the received error is not a RestError, it is immediately thrown.
88973-
responseError = e;
88974-
if (!e || responseError.name !== "RestError") {
89035+
if (!restError_isRestError(e)) {
8897589036
throw e;
8897689037
}
88977-
response = responseError.response;
89038+
responseError = e;
89039+
response = e.response;
8897889040
}
8897989041
if (request.abortSignal?.aborted) {
8898089042
logger.error(`Retry ${retryCount}: Request aborted.`);
@@ -89375,16 +89437,15 @@ function setProxyAgentOnRequest(request, cachedAgents, proxyUrl) {
8937589437
if (request.tlsSettings) {
8937689438
log_logger.warning("TLS settings are not supported in combination with custom Proxy, certificates provided to the client will be ignored.");
8937789439
}
89378-
const headers = request.headers.toJSON();
8937989440
if (isInsecure) {
8938089441
if (!cachedAgents.httpProxyAgent) {
89381-
cachedAgents.httpProxyAgent = new http_proxy_agent_dist.HttpProxyAgent(proxyUrl, { headers });
89442+
cachedAgents.httpProxyAgent = new http_proxy_agent_dist.HttpProxyAgent(proxyUrl);
8938289443
}
8938389444
request.agent = cachedAgents.httpProxyAgent;
8938489445
}
8938589446
else {
8938689447
if (!cachedAgents.httpsProxyAgent) {
89387-
cachedAgents.httpsProxyAgent = new dist.HttpsProxyAgent(proxyUrl, { headers });
89448+
cachedAgents.httpsProxyAgent = new dist.HttpsProxyAgent(proxyUrl);
8938889449
}
8938989450
request.agent = cachedAgents.httpsProxyAgent;
8939089451
}
@@ -89436,13 +89497,13 @@ function typeGuards_isBinaryBody(body) {
8943689497
(body instanceof Uint8Array ||
8943789498
typeGuards_isReadableStream(body) ||
8943889499
typeof body === "function" ||
89439-
body instanceof Blob));
89500+
(typeof Blob !== "undefined" && body instanceof Blob)));
8944089501
}
8944189502
function typeGuards_isReadableStream(x) {
8944289503
return isNodeReadableStream(x) || isWebReadableStream(x);
8944389504
}
89444-
function isBlob(x) {
89445-
return typeof x.stream === "function";
89505+
function typeGuards_isBlob(x) {
89506+
return typeof Blob !== "undefined" && x instanceof Blob;
8944689507
}
8944789508
//# sourceMappingURL=typeGuards.js.map
8944889509
// EXTERNAL MODULE: external "stream"
@@ -89488,7 +89549,7 @@ function toStream(source) {
8948889549
if (source instanceof Uint8Array) {
8948989550
return external_stream_.Readable.from(Buffer.from(source));
8949089551
}
89491-
else if (isBlob(source)) {
89552+
else if (typeGuards_isBlob(source)) {
8949289553
return ensureNodeStream(source.stream());
8949389554
}
8949489555
else {
@@ -89538,7 +89599,7 @@ function getLength(source) {
8953889599
if (source instanceof Uint8Array) {
8953989600
return source.byteLength;
8954089601
}
89541-
else if (isBlob(source)) {
89602+
else if (typeGuards_isBlob(source)) {
8954289603
// if was created using createFile then -1 means we have an unknown size
8954389604
return source.size === -1 ? undefined : source.size;
8954489605
}
@@ -90067,9 +90128,14 @@ async function sendRequest_sendRequest(method, url, pipeline, options = {}, cust
9006790128
* @returns returns the content-type
9006890129
*/
9006990130
function getRequestContentType(options = {}) {
90070-
return (options.contentType ??
90071-
options.headers?.["content-type"] ??
90072-
getContentType(options.body));
90131+
if (options.contentType) {
90132+
return options.contentType;
90133+
}
90134+
const headerContentType = options.headers?.["content-type"];
90135+
if (typeof headerContentType === "string") {
90136+
return headerContentType;
90137+
}
90138+
return getContentType(options.body);
9007390139
}
9007490140
/**
9007590141
* Function to determine the content-type of a body
@@ -90084,6 +90150,9 @@ function getContentType(body) {
9008490150
if (ArrayBuffer.isView(body)) {
9008590151
return "application/octet-stream";
9008690152
}
90153+
if (isBlob(body) && body.type) {
90154+
return body.type;
90155+
}
9008790156
if (typeof body === "string") {
9008890157
try {
9008990158
JSON.parse(body);
@@ -90134,9 +90203,15 @@ function getRequestBody(body, contentType = "") {
9013490203
if (typeof FormData !== "undefined" && body instanceof FormData) {
9013590204
return { body };
9013690205
}
90206+
if (isBlob(body)) {
90207+
return { body };
90208+
}
9013790209
if (isReadableStream(body)) {
9013890210
return { body };
9013990211
}
90212+
if (typeof body === "function") {
90213+
return { body: body };
90214+
}
9014090215
if (ArrayBuffer.isView(body)) {
9014190216
return { body: body instanceof Uint8Array ? body : JSON.stringify(body) };
9014290217
}
@@ -90326,8 +90401,6 @@ function statusCodeToNumber(statusCode) {
9032690401

9032790402

9032890403

90329-
90330-
9033190404
//# sourceMappingURL=index.js.map
9033290405
;// CONCATENATED MODULE: ./node_modules/@azure/core-rest-pipeline/dist/esm/pipeline.js
9033390406
// Copyright (c) Microsoft Corporation.
@@ -90524,59 +90597,6 @@ function throttlingRetryPolicy(options = {}) {
9052490597
};
9052590598
}
9052690599
//# sourceMappingURL=throttlingRetryPolicy.js.map
90527-
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/policies/redirectPolicy.js
90528-
// Copyright (c) Microsoft Corporation.
90529-
// Licensed under the MIT License.
90530-
/**
90531-
* The programmatic identifier of the redirectPolicy.
90532-
*/
90533-
const redirectPolicyName = "redirectPolicy";
90534-
/**
90535-
* Methods that are allowed to follow redirects 301 and 302
90536-
*/
90537-
const allowedRedirect = ["GET", "HEAD"];
90538-
/**
90539-
* A policy to follow Location headers from the server in order
90540-
* to support server-side redirection.
90541-
* In the browser, this policy is not used.
90542-
* @param options - Options to control policy behavior.
90543-
*/
90544-
function redirectPolicy_redirectPolicy(options = {}) {
90545-
const { maxRetries = 20 } = options;
90546-
return {
90547-
name: redirectPolicyName,
90548-
async sendRequest(request, next) {
90549-
const response = await next(request);
90550-
return handleRedirect(next, response, maxRetries);
90551-
},
90552-
};
90553-
}
90554-
async function handleRedirect(next, response, maxRetries, currentRetries = 0) {
90555-
const { request, status, headers } = response;
90556-
const locationHeader = headers.get("location");
90557-
if (locationHeader &&
90558-
(status === 300 ||
90559-
(status === 301 && allowedRedirect.includes(request.method)) ||
90560-
(status === 302 && allowedRedirect.includes(request.method)) ||
90561-
(status === 303 && request.method === "POST") ||
90562-
status === 307) &&
90563-
currentRetries < maxRetries) {
90564-
const url = new URL(locationHeader, request.url);
90565-
request.url = url.toString();
90566-
// POST request with Status code 303 should be converted into a
90567-
// redirected GET request if the redirect url is present in the location header
90568-
if (status === 303) {
90569-
request.method = "GET";
90570-
request.headers.delete("Content-Length");
90571-
delete request.body;
90572-
}
90573-
request.headers.delete("Authorization");
90574-
const res = await next(request);
90575-
return handleRedirect(next, res, maxRetries, currentRetries + 1);
90576-
}
90577-
return response;
90578-
}
90579-
//# sourceMappingURL=redirectPolicy.js.map
9058090600
;// CONCATENATED MODULE: ./node_modules/@typespec/ts-http-runtime/dist/esm/policies/tlsPolicy.js
9058190601
// Copyright (c) Microsoft Corporation.
9058290602
// Licensed under the MIT License.

0 commit comments

Comments
 (0)