Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
const path = require('path');
const fs = require('fs');
const ms = require('ms');
const is = require('is-type-of');
const graceful = require('graceful');
const http = require('http');
const cluster = require('cluster-client');
const onFinished = require('on-finished');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;
const EggApplication = require('./egg');
const AppWorkerLoader = require('./loader').AppWorkerLoader;
const KEYS = Symbol('Application#keys');
const HELPER = Symbol('Application#Helper');
const LOCALS = Symbol('Application#locals');
const BIND_EVENTS = Symbol('Application#bindEvents');
const WARN_CONFUSED_CONFIG = Symbol('Application#warnConfusedConfig');
const EGG_LOADER = Symbol.for('egg#loader');
const EGG_PATH = Symbol.for('egg#eggPath');
const CLUSTER_CLIENTS = Symbol.for('egg#clusterClients');
const RESPONSE_RAW = Symbol('Application#responseRaw');
// client error => 400 Bad Request
// Refs: https://nodejs.org/dist/latest-v8.x/docs/api/http.html#http_event_clienterror
const DEFAULT_BAD_REQUEST_HTML = `
'use strict';
// try to use eggUtils.getCalleeFromStack
// ignore it if egg-core module not found
let eggUtils;
try {
eggUtils = require('egg-core').utils;
if (!eggUtils) {
// try to support egg-core@3
eggUtils = require('egg-core/lib/utils');
}
} catch (_) {
// ignore eggUtils
}
module.exports = {
runInBackground(scope) {
/* istanbul ignore next */
const taskName = scope._name || scope.name || (eggUtils && eggUtils.getCalleeFromStack(true));
if (taskName) {
scope._name = taskName;
}
'use strict';
const delegate = require('delegates');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;
const HELPER = Symbol('Context#helper');
const LOCALS = Symbol('Context#locals');
const LOCALS_LIST = Symbol('Context#localsList');
const COOKIES = Symbol('Context#cookies');
const CONTEXT_LOGGERS = Symbol('Context#logger');
const CONTEXT_HTTPCLIENT = Symbol('Context#httpclient');
const CONTEXT_ROUTER = Symbol('Context#router');
const proto = module.exports = {
/**
* Get the current visitor's cookies.
*/
get cookies() {
if (!this[COOKIES]) {
'use strict';
const delegate = require('delegates');
const { assign } = require('utility');
const eggUtils = require('egg-core').utils;
const HELPER = Symbol('Context#helper');
const LOCALS = Symbol('Context#locals');
const LOCALS_LIST = Symbol('Context#localsList');
const COOKIES = Symbol('Context#cookies');
const CONTEXT_LOGGERS = Symbol('Context#logger');
const CONTEXT_HTTPCLIENT = Symbol('Context#httpclient');
const CONTEXT_ROUTER = Symbol('Context#router');
const proto = module.exports = {
/**
* Get the current visitor's cookies.
*/
get cookies() {
if (!this[COOKIES]) {