mirror of
https://github.com/denoland/deno.git
synced 2024-12-12 02:27:46 -05:00
wip
This commit is contained in:
parent
e98525c0a0
commit
65eb113359
1 changed files with 45 additions and 20 deletions
|
@ -423,18 +423,20 @@ class ClientRequest extends OutgoingMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
_writeHeader() {
|
_writeHeader() {
|
||||||
console.trace("_writeHeader invoked");
|
console.trace("_writeHeader invoked am i working?");
|
||||||
const url = this._createUrlStrFromOptions();
|
const url = this._createUrlStrFromOptions();
|
||||||
|
console.log({ url });
|
||||||
|
// const headers = [];
|
||||||
|
// for (const key in this[kOutHeaders]) {
|
||||||
|
// if (Object.hasOwn(this[kOutHeaders], key)) {
|
||||||
|
// const entry = this[kOutHeaders][key];
|
||||||
|
// console.log("processing header");
|
||||||
|
// this._processHeader(headers, entry[0], entry[1], false);
|
||||||
|
// console.log("processing header done");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
const headers = [];
|
// console.log("im here", { headers });
|
||||||
for (const key in this[kOutHeaders]) {
|
|
||||||
if (Object.hasOwn(this[kOutHeaders], key)) {
|
|
||||||
const entry = this[kOutHeaders][key];
|
|
||||||
this._processHeader(headers, entry[0], entry[1], false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log({ headers });
|
|
||||||
// const client = this._getClient() ?? createHttpClient({ http2: false });
|
// const client = this._getClient() ?? createHttpClient({ http2: false });
|
||||||
// this._client = client;
|
// this._client = client;
|
||||||
|
|
||||||
|
@ -615,11 +617,15 @@ class ClientRequest extends OutgoingMessage {
|
||||||
// Flush the internal buffers once socket is ready.
|
// Flush the internal buffers once socket is ready.
|
||||||
// Note: the order is important, as the headers flush
|
// Note: the order is important, as the headers flush
|
||||||
// sets up the request.
|
// sets up the request.
|
||||||
this._flushHeaders();
|
try {
|
||||||
this.on("requestReady", () => {
|
this._flushHeaders();
|
||||||
console.log("onSocket: flushing body");
|
this.on("requestReady", () => {
|
||||||
this._flushBody();
|
console.log("onSocket: flushing body");
|
||||||
});
|
this._flushBody();
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("socket error: ", error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
this.emit("socket", socket);
|
this.emit("socket", socket);
|
||||||
|
@ -773,25 +779,44 @@ class ClientRequest extends OutgoingMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
_createUrlStrFromOptions(): string {
|
_createUrlStrFromOptions(): string {
|
||||||
|
console.log("_createUrlStrFromOptions");
|
||||||
if (this.href) {
|
if (this.href) {
|
||||||
return this.href;
|
return this.href;
|
||||||
}
|
}
|
||||||
|
console.log("_createUrlStrFromOptions 2");
|
||||||
const protocol = this.protocol ?? this.defaultProtocol;
|
const protocol = this.protocol ?? this.defaultProtocol;
|
||||||
|
console.log("_createUrlStrFromOptions 3");
|
||||||
const auth = this.auth;
|
const auth = this.auth;
|
||||||
|
console.log("_createUrlStrFromOptions 4");
|
||||||
const host = this.host ?? this.hostname ?? "localhost";
|
const host = this.host ?? this.hostname ?? "localhost";
|
||||||
|
console.log("_createUrlStrFromOptions 5");
|
||||||
const hash = this.hash ? `#${this.hash}` : "";
|
const hash = this.hash ? `#${this.hash}` : "";
|
||||||
|
console.log("_createUrlStrFromOptions 6");
|
||||||
const defaultPort = this.agent?.defaultPort;
|
const defaultPort = this.agent?.defaultPort;
|
||||||
|
console.log("_createUrlStrFromOptions 7");
|
||||||
const port = this.port ?? defaultPort ?? 80;
|
const port = this.port ?? defaultPort ?? 80;
|
||||||
|
console.log("_createUrlStrFromOptions 8");
|
||||||
let path = this.path ?? "/";
|
let path = this.path ?? "/";
|
||||||
if (!path.startsWith("/")) {
|
if (!path.startsWith("/")) {
|
||||||
path = "/" + path;
|
path = "/" + path;
|
||||||
}
|
}
|
||||||
const url = new URL(
|
console.log("_createUrlStrFromOptions 9");
|
||||||
`${protocol}//${auth ? `${auth}@` : ""}${host}${
|
// try {
|
||||||
port === 80 ? "" : `:${port}`
|
console.log({ url: `${protocol}//${auth ? `${auth}@` : ""}${host}${
|
||||||
}${path}`,
|
port === 80 ? "" : `:${port}`
|
||||||
);
|
}${path}` })
|
||||||
|
const url = new URL(
|
||||||
|
`${protocol}//${auth ? `${auth}@` : ""}${host}${
|
||||||
|
port === 80 ? "" : `:${port}`
|
||||||
|
}${path}`,
|
||||||
|
);
|
||||||
|
console.log(url);
|
||||||
|
// } catch (error) {
|
||||||
|
// console.log({ error })
|
||||||
|
// }
|
||||||
|
console.log("_createUrlStrFromOptions 10");
|
||||||
url.hash = hash;
|
url.hash = hash;
|
||||||
|
console.log("_createUrlStrFromOptions end");
|
||||||
return url.href;
|
return url.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue