CI / Docker image (push) Successful in 12s
CI / Server (push) Successful in 25s
CI / CLI (push) Successful in 13s
Development image / Development image (push) Successful in 21s
CI / CLI (windows) (push) Successful in 57s
CI / CLI (linux-arm64, static) (push) Successful in 1m37s
Release / Prepare release (push) Successful in 2s
Release / Server (linux-x64) (push) Successful in 53s
Release / CLI (linux-arm64, static) (push) Successful in 1m32s
Release / Docker image (push) Successful in 2m48s
Release / Server (windows-x64) (push) Successful in 6m20s
Release / CLI (windows-x64) (push) Successful in 6m48s
Release / CLI (linux-x64) (push) Successful in 7m8s
Release / Publish release (push) Successful in 1s
Squash the tree into one commit, drop docs/architecture.html, reset the version line to 0.3.0, consolidate the changelog, enable Renovate automerge for non-major updates and add AGENTS.md.
64 lines
2.4 KiB
JavaScript
64 lines
2.4 KiB
JavaScript
const packageJson = require("../../package.json");
|
|
|
|
const pairs = list => list.map(([name, value]) => ({ name, value }));
|
|
|
|
const header = (list, wanted) => list.find(([name]) => name.toLowerCase() === wanted)?.[1] ?? "";
|
|
|
|
const text = body => {
|
|
if (!body) return undefined;
|
|
const bytes = Buffer.from(body, "base64");
|
|
const decoded = bytes.toString("utf8");
|
|
return Buffer.from(decoded, "utf8").equals(bytes) ? { text: decoded } : { text: body, encoding: "base64" };
|
|
};
|
|
|
|
const message = frame => ({
|
|
type: frame.direction === "in" ? "send" : "receive",
|
|
time: frame.time / 1000,
|
|
opcode: frame.opcode,
|
|
data: frame.payload ? Buffer.from(frame.payload, "base64").toString(frame.opcode === 1 ? "utf8" : "base64") : "",
|
|
});
|
|
|
|
const entry = (row, scheme, frames) => {
|
|
const url = new URL(row.path, `${scheme}://${row.host}`);
|
|
return {
|
|
startedDateTime: new Date(row.time).toISOString(),
|
|
time: row.duration,
|
|
request: {
|
|
method: row.kind === "ws" ? "GET" : row.method,
|
|
url: url.toString(),
|
|
httpVersion: "HTTP/1.1",
|
|
cookies: [],
|
|
headers: pairs(row.request.headers),
|
|
queryString: pairs([...url.searchParams]),
|
|
headersSize: -1,
|
|
bodySize: row.request.bytes,
|
|
...(row.request.body && { postData: { mimeType: header(row.request.headers, "content-type"), ...text(row.request.body) } }),
|
|
},
|
|
response: {
|
|
status: row.status ?? 0,
|
|
statusText: "",
|
|
httpVersion: "HTTP/1.1",
|
|
cookies: [],
|
|
headers: pairs(row.response.headers),
|
|
content: { size: row.response.bytes, mimeType: header(row.response.headers, "content-type"), ...text(row.response.body) },
|
|
redirectURL: header(row.response.headers, "location"),
|
|
headersSize: -1,
|
|
bodySize: row.response.bytes,
|
|
},
|
|
cache: {},
|
|
timings: { send: 0, wait: row.duration, receive: 0 },
|
|
...(row.ip && { serverIPAddress: row.ip }),
|
|
...(row.kind === "ws" && { _webSocketMessages: (frames.get(row.connection) || []).map(message) }),
|
|
};
|
|
};
|
|
|
|
const toHar = (rows, scheme, frames) => ({
|
|
log: {
|
|
version: "1.2",
|
|
creator: { name: "frislit", version: packageJson.version },
|
|
entries: rows.map(row => entry(row, scheme, frames)),
|
|
},
|
|
});
|
|
|
|
module.exports = { toHar };
|