heartbeat-monitor/node_modules/next/dist/server/send-response.js
Matt Bruce bed1169443 Initial commit: Heartbeat Monitor dashboard
- Full-featured monitoring dashboard for local web apps
- Real-time status tracking with uptime percentages
- Visual sparklines for status history
- Add/Edit/Delete apps dynamically
- Categories and color coding
- Auto-refresh every 30 seconds
- API endpoints for apps and status management
2026-02-18 11:16:01 -06:00

60 lines
2.6 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "sendResponse", {
enumerable: true,
get: function() {
return sendResponse;
}
});
const _helpers = require("./base-http/helpers");
const _pipereadable = require("./pipe-readable");
const _utils = require("./web/utils");
async function sendResponse(req, res, response, waitUntil) {
if (// The type check here ensures that `req` is correctly typed, and the
// environment variable check provides dead code elimination.
process.env.NEXT_RUNTIME !== 'edge' && (0, _helpers.isNodeNextResponse)(res)) {
var // Copy over the response headers.
_response_headers;
// Copy over the response status.
res.statusCode = response.status;
res.statusMessage = response.statusText;
// can add more headers to this list if needed
const headersWithMultipleValuesAllowed = [
'set-cookie',
'www-authenticate',
'proxy-authenticate'
];
(_response_headers = response.headers) == null ? void 0 : _response_headers.forEach((value, name)=>{
// The append handling is special cased for `set-cookie`.
if (name.toLowerCase() === 'set-cookie') {
// TODO: (wyattjoh) replace with native response iteration when we can upgrade undici
for (const cookie of (0, _utils.splitCookiesString)(value)){
res.appendHeader(name, cookie);
}
} else {
// only append the header if it is either not present in the outbound response
// or if the header supports multiple values
const isHeaderPresent = typeof res.getHeader(name) !== 'undefined';
if (headersWithMultipleValuesAllowed.includes(name.toLowerCase()) || !isHeaderPresent) {
res.appendHeader(name, value);
}
}
});
/**
* The response can't be directly piped to the underlying response. The
* following is duplicated from the edge runtime handler.
*
* See packages/next/server/next-server.ts
*/ const { originalResponse } = res;
// A response body must not be sent for HEAD requests. See https://httpwg.org/specs/rfc9110.html#HEAD
if (response.body && req.method !== 'HEAD') {
await (0, _pipereadable.pipeToNodeResponse)(response.body, originalResponse, waitUntil);
} else {
originalResponse.end();
}
}
}
//# sourceMappingURL=send-response.js.map