mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Fixes node:http and node:stream so ytdl-core works. (#3452)
* fix crash in readablestate * make node:https request+get actually use https * use a native readablestream in IncomingMessage * tweaks * fix abort crash * emit close by default * remove abort. this isnt a real function * add validate functions, fixup some other requested changes. not done yet * Update WebCoreJSBuiltins.cpp * Update JSReadableState.cpp * Add some missing exports --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
65
src/js/node/https.ts
Normal file
65
src/js/node/https.ts
Normal file
@@ -0,0 +1,65 @@
|
||||
// Hardcoded module "node:https"
|
||||
import * as http from "node:http";
|
||||
|
||||
var {
|
||||
Agent,
|
||||
Server,
|
||||
METHODS,
|
||||
STATUS_CODES,
|
||||
createServer,
|
||||
ServerResponse,
|
||||
IncomingMessage,
|
||||
maxHeaderSize,
|
||||
validateHeaderName,
|
||||
validateHeaderValue,
|
||||
globalAgent,
|
||||
} = http;
|
||||
|
||||
function request(input, options, cb) {
|
||||
if (input && typeof input === "object" && !(input instanceof URL)) {
|
||||
input.protocol ??= "https:";
|
||||
} else if (typeof options === "object") {
|
||||
options.protocol ??= "https:";
|
||||
}
|
||||
|
||||
return http.request(input, options, cb);
|
||||
}
|
||||
|
||||
function get(input, options, cb) {
|
||||
const req = request(input, options, cb);
|
||||
req.end();
|
||||
return req;
|
||||
}
|
||||
|
||||
var defaultExport = {
|
||||
Agent,
|
||||
Server,
|
||||
METHODS,
|
||||
STATUS_CODES,
|
||||
createServer,
|
||||
ServerResponse,
|
||||
IncomingMessage,
|
||||
request,
|
||||
get,
|
||||
maxHeaderSize,
|
||||
validateHeaderName,
|
||||
validateHeaderValue,
|
||||
globalAgent,
|
||||
};
|
||||
|
||||
export {
|
||||
Agent,
|
||||
Server,
|
||||
METHODS,
|
||||
STATUS_CODES,
|
||||
createServer,
|
||||
ServerResponse,
|
||||
IncomingMessage,
|
||||
request,
|
||||
get,
|
||||
maxHeaderSize,
|
||||
validateHeaderName,
|
||||
validateHeaderValue,
|
||||
globalAgent,
|
||||
};
|
||||
export default defaultExport;
|
||||
Reference in New Issue
Block a user