How to use the on-finished.isFinished function in on-finished

To help you get started, we’ve selected a few on-finished examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jfhbrook / node-ecstatic / lib / ecstatic.js View on Github external
function serve(stat) {
      if (onFinished.isFinished(res)) {
        return;
      }

      // Do a MIME lookup, fall back to octet-stream and handle gzip
      // and brotli special case.
      const defaultType = opts.contentType || 'application/octet-stream';

      let contentType = mime.getType(file, defaultType);
      let charSet;
      const range = (req.headers && req.headers.range);
      const lastModified = (new Date(stat.mtime)).toUTCString();
      const etag = generateEtag(stat, weakEtags);
      let cacheControl = cache;
      if (contentType) {
        charSet = mime.lookupCharset(contentType);
        if (charSet) {
github fontello / fontello / lib / autoload / hooks / responder / response_send.js View on Github external
N.wire.after(CHANNELS, { priority: 100 }, function response_send(env) {
    var res = env.origin.res,
        headers = env.headers,
        body = env.body,
        statusCode;

    // If someone already sent reply - do nothing
    if (isFinished(res)) return;

    // That should not happen, because custom senders should wait
    // stream end.
    if (res.headerSent) return;

    //
    // Set some obligatory headers
    //

    headers.Server = headers.Server || 'Sansun Calakci';
    // added by node automatically
    // headers['Date'] = headers['Date'] || new Date).toUTCString();

    //
    // Remove Accept-Ranges if it wasn't explicitly set
    //
github nodeca / nodeca.core / lib / autoload / hooks / responder / response_send.js View on Github external
N.wire.after(CHANNELS, { priority: 100 }, function response_send(env) {
    var res = env.origin.res,
        headers = env.headers,
        body = env.body,
        statusCode;

    // If someone already sent reply - do nothing
    if (isFinished(res)) return;

    // That should not happen, because custom senders should wait
    // stream end.
    if (res.headerSent) return;

    //
    // Set some obligatory headers
    //

    headers.Server = headers.Server || 'Sansun Calakci';
    // added by node automatically
    // headers['Date'] = headers['Date'] || new Date).toUTCString();

    //
    // Remove Accept-Ranges if it wasn't explicitly set
    //
github http-party / http-server / lib / ecstatic.js View on Github external
function serve(stat) {
      if (onFinished.isFinished(res)) {
        return;
      }

      // Do a MIME lookup, fall back to octet-stream and handle gzip
      // and brotli special case.
      const defaultType = opts.contentType || 'application/octet-stream';

      let contentType = mime.getType(file, defaultType);
      let charSet;
      const range = (req.headers && req.headers.range);
      const lastModified = (new Date(stat.mtime)).toUTCString();
      const etag = generateEtag(stat, weakEtags);
      let cacheControl = cache;
      if (contentType) {
        charSet = mime.lookupCharset(contentType);
        if (charSet) {

on-finished

Execute a callback when a request closes, finishes, or errors

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular on-finished functions

Similar packages