Skip to content

Instantly share code, notes, and snippets.

@ryanwoodsmall
Created September 6, 2025 20:14
Show Gist options
  • Select an option

  • Save ryanwoodsmall/462f6570cb8d7bb5e97faa8c1e46f430 to your computer and use it in GitHub Desktop.

Select an option

Save ryanwoodsmall/462f6570cb8d7bb5e97faa8c1e46f430 to your computer and use it in GitHub Desktop.
quickjs-parse-headers.js
var r = std.urlGet("http://your.host.name:12345/tmp/blah.out", {binary: true, full: true});
function parseHeaders(r) {
var h = {};
var a = r.responseHeaders.split(/\r\n/);
for (const l of a) {
const t = l.toString().trim().split(":");
const k = t.shift().toString().trim();
if (k.length != 0) {
const v = t.join(":").toString().trim();
h[k] = v;
}
}
return(JSON.stringify(h));
}
var hh = parseHeaders(r);
console.log(hh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment