@@ -38236,10 +38236,11 @@ function discoverFromDistributionJson(codeqlStorage) {
3823638236 "codeql",
3823738237 CODEQL_BINARY_NAME
3823838238 );
38239- if (existsSync2 (binaryPath)) {
38239+ if (isExecutableBinary (binaryPath)) {
3824038240 logger.debug(`Discovered CLI via distribution.json (folderIndex=${data.folderIndex})`);
3824138241 return binaryPath;
3824238242 }
38243+ logger.debug(`distribution.json hint (folderIndex=${data.folderIndex}) exists but is not a usable executable; falling through to scan`);
3824338244 } catch {
3824438245 }
3824538246 return void 0;
@@ -38258,7 +38259,7 @@ function discoverFromDistributionScan(codeqlStorage) {
3825838259 "codeql",
3825938260 CODEQL_BINARY_NAME
3826038261 );
38261- if (existsSync2 (binaryPath)) {
38262+ if (isExecutableBinary (binaryPath)) {
3826238263 logger.debug(`Discovered CLI via distribution scan: ${dir.name}`);
3826338264 return binaryPath;
3826438265 }
@@ -38284,17 +38285,12 @@ function resolveCodeQLBinary(candidateStorageRoots) {
3828438285 const envPath = process.env.CODEQL_PATH;
3828538286 if (!envPath) {
3828638287 const discovered = discoverVsCodeCodeQLDistribution(candidateStorageRoots);
38287- if (discovered && isExecutableBinary(discovered) ) {
38288+ if (discovered) {
3828838289 resolvedCodeQLDir = dirname2(discovered);
3828938290 resolvedBinaryResult = "codeql";
3829038291 logger.info(`CodeQL CLI auto-discovered via vscode-codeql distribution: ${discovered} (dir: ${resolvedCodeQLDir})`);
3829138292 return resolvedBinaryResult;
3829238293 }
38293- if (discovered) {
38294- logger.warn(
38295- `Discovered vscode-codeql distribution at ${discovered} but the binary is not a regular executable file; falling back to PATH lookup`
38296- );
38297- }
3829838294 resolvedCodeQLDir = null;
3829938295 resolvedBinaryResult = "codeql";
3830038296 return resolvedBinaryResult;
@@ -55662,15 +55658,17 @@ var Response2 = class _Response {
5566255658 this.#init = init;
5566355659 }
5566455660 if (typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array) {
55665- headers ||= init?.headers || { "content-type": "text/plain; charset=UTF-8" } ;
55666- this[cacheKey] = [init?.status || 200, body, headers];
55661+ ;
55662+ this[cacheKey] = [init?.status || 200, body, headers || init?.headers ];
5566755663 }
5566855664 }
5566955665 get headers() {
5567055666 const cache = this[cacheKey];
5567155667 if (cache) {
5567255668 if (!(cache[2] instanceof Headers)) {
55673- cache[2] = new Headers(cache[2]);
55669+ cache[2] = new Headers(
55670+ cache[2] || { "content-type": "text/plain; charset=UTF-8" }
55671+ );
5567455672 }
5567555673 return cache[2];
5567655674 }
@@ -55795,15 +55793,32 @@ var flushHeaders = (outgoing) => {
5579555793};
5579655794var responseViaCache = async (res, outgoing) => {
5579755795 let [status, body, header] = res[cacheKey];
55798- if (header instanceof Headers) {
55796+ let hasContentLength = false;
55797+ if (!header) {
55798+ header = { "content-type": "text/plain; charset=UTF-8" };
55799+ } else if (header instanceof Headers) {
55800+ hasContentLength = header.has("content-length");
5579955801 header = buildOutgoingHttpHeaders(header);
55802+ } else if (Array.isArray(header)) {
55803+ const headerObj = new Headers(header);
55804+ hasContentLength = headerObj.has("content-length");
55805+ header = buildOutgoingHttpHeaders(headerObj);
55806+ } else {
55807+ for (const key in header) {
55808+ if (key.length === 14 && key.toLowerCase() === "content-length") {
55809+ hasContentLength = true;
55810+ break;
55811+ }
55812+ }
5580055813 }
55801- if (typeof body === "string") {
55802- header["Content-Length"] = Buffer.byteLength(body);
55803- } else if (body instanceof Uint8Array) {
55804- header["Content-Length"] = body.byteLength;
55805- } else if (body instanceof Blob) {
55806- header["Content-Length"] = body.size;
55814+ if (!hasContentLength) {
55815+ if (typeof body === "string") {
55816+ header["Content-Length"] = Buffer.byteLength(body);
55817+ } else if (body instanceof Uint8Array) {
55818+ header["Content-Length"] = body.byteLength;
55819+ } else if (body instanceof Blob) {
55820+ header["Content-Length"] = body.size;
55821+ }
5580755822 }
5580855823 outgoing.writeHead(status, header);
5580955824 if (typeof body === "string" || body instanceof Uint8Array) {
0 commit comments