mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
…s` (#26323)"
This reverts commit afb33b3c25
.
Reverting because it caused a regression -
https://github.com/denoland/deno/issues/26612.
Closes https://github.com/denoland/deno/issues/26612.
This commit is contained in:
parent
484f8ca9c3
commit
46e5ed1a64
1 changed files with 12 additions and 19 deletions
|
@ -1,6 +1,9 @@
|
||||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||||
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
||||||
|
|
||||||
|
// TODO(petamoriken): enable prefer-primordials for node polyfills
|
||||||
|
// deno-lint-ignore-file prefer-primordials
|
||||||
|
|
||||||
import { notImplemented } from "ext:deno_node/_utils.ts";
|
import { notImplemented } from "ext:deno_node/_utils.ts";
|
||||||
import { urlToHttpOptions } from "ext:deno_node/internal/url.ts";
|
import { urlToHttpOptions } from "ext:deno_node/internal/url.ts";
|
||||||
import {
|
import {
|
||||||
|
@ -14,14 +17,6 @@ import { type ServerHandler, ServerImpl as HttpServer } from "node:http";
|
||||||
import { validateObject } from "ext:deno_node/internal/validators.mjs";
|
import { validateObject } from "ext:deno_node/internal/validators.mjs";
|
||||||
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
import { kEmptyObject } from "ext:deno_node/internal/util.mjs";
|
||||||
import { Buffer } from "node:buffer";
|
import { Buffer } from "node:buffer";
|
||||||
import { primordials } from "ext:core/mod.js";
|
|
||||||
const {
|
|
||||||
ArrayPrototypeShift,
|
|
||||||
ArrayPrototypeUnshift,
|
|
||||||
ArrayIsArray,
|
|
||||||
ObjectPrototypeIsPrototypeOf,
|
|
||||||
ObjectAssign,
|
|
||||||
} = primordials;
|
|
||||||
|
|
||||||
export class Server extends HttpServer {
|
export class Server extends HttpServer {
|
||||||
constructor(opts, requestListener?: ServerHandler) {
|
constructor(opts, requestListener?: ServerHandler) {
|
||||||
|
@ -34,11 +29,11 @@ export class Server extends HttpServer {
|
||||||
validateObject(opts, "options");
|
validateObject(opts, "options");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.cert && ArrayIsArray(opts.cert)) {
|
if (opts.cert && Array.isArray(opts.cert)) {
|
||||||
notImplemented("https.Server.opts.cert array type");
|
notImplemented("https.Server.opts.cert array type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.key && ArrayIsArray(opts.key)) {
|
if (opts.key && Array.isArray(opts.key)) {
|
||||||
notImplemented("https.Server.opts.key array type");
|
notImplemented("https.Server.opts.key array type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +42,10 @@ export class Server extends HttpServer {
|
||||||
|
|
||||||
_additionalServeOptions() {
|
_additionalServeOptions() {
|
||||||
return {
|
return {
|
||||||
cert: ObjectPrototypeIsPrototypeOf(Buffer, this._opts.cert)
|
cert: this._opts.cert instanceof Buffer
|
||||||
// deno-lint-ignore prefer-primordials
|
|
||||||
? this._opts.cert.toString()
|
? this._opts.cert.toString()
|
||||||
: this._opts.cert,
|
: this._opts.cert,
|
||||||
key: ObjectPrototypeIsPrototypeOf(Buffer, this._opts.key)
|
key: this._opts.key instanceof Buffer
|
||||||
// deno-lint-ignore prefer-primordials
|
|
||||||
? this._opts.key.toString()
|
? this._opts.key.toString()
|
||||||
: this._opts.key,
|
: this._opts.key,
|
||||||
};
|
};
|
||||||
|
@ -166,18 +159,18 @@ export function request(...args: any[]) {
|
||||||
let options = {};
|
let options = {};
|
||||||
|
|
||||||
if (typeof args[0] === "string") {
|
if (typeof args[0] === "string") {
|
||||||
const urlStr = ArrayPrototypeShift(args);
|
const urlStr = args.shift();
|
||||||
options = urlToHttpOptions(new URL(urlStr));
|
options = urlToHttpOptions(new URL(urlStr));
|
||||||
} else if (ObjectPrototypeIsPrototypeOf(URL, args[0])) {
|
} else if (args[0] instanceof URL) {
|
||||||
options = urlToHttpOptions(ArrayPrototypeShift(args));
|
options = urlToHttpOptions(args.shift());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] && typeof args[0] !== "function") {
|
if (args[0] && typeof args[0] !== "function") {
|
||||||
ObjectAssign(options, ArrayPrototypeShift(args));
|
Object.assign(options, args.shift());
|
||||||
}
|
}
|
||||||
|
|
||||||
options._defaultAgent = globalAgent;
|
options._defaultAgent = globalAgent;
|
||||||
ArrayPrototypeUnshift(args, options);
|
args.unshift(options);
|
||||||
|
|
||||||
return new HttpsClientRequest(args[0], args[1]);
|
return new HttpsClientRequest(args[0], args[1]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue