<commit_before>const logger = require('ezzy-logger').logger;
const DEFAULT_CONTENT_TYPE = '*/*';
const {version, name, description} = require('./package');
let inst;

/**
 * Base class that handles a request.
 */
class Request {

  /**
   * Constructor.
   */
  constructor() {
    /**
     * The context in which this request is bound.
     * @type {string|null}
     * @private
     */
    this._context = null;

    /**
     * The custom errors to use when displaying status codes.
     * @type {null|Promise}
     * @private
     */
    this._errors = null;
  }

  /**
   * Flag that could be turned on or off to indicate if we need to send headers.
   * @returns {boolean}
   */
  get sendHeaders() {
    return true;
  }

  /**
   * Default request instance.
   * @returns {Request}
   */
  static get inst() {
    if (!inst) {
      inst = new Request();
    }
    return inst;
  }

  /**
   * The context of the request.
   * @returns {string|null}
   */
  get context() {
    return this._context;
  }

  /**
   * The context of the request.
   * @param {string|null} val The context of the request.
   */
  set context(val) {
    this._context = val;
  }

  /**
   * Handles the request based on method.
   * @param {HttpBasics} basics The HTTP Basics.
   */
  doRequest(basics) {
    const {method, hostname, originalUrl} = basics.request;

    logger
      .debug('Interception', `Request intercepted by ${this.constructor.name}`);

    if (!this.isRequestOk(basics)) {
      return this.requestNotOk(basics);
    } else {
      logger.debug('Request', `${method} ${hostname} ${originalUrl}`);
    }

    const auth = this.auth(basics);
    if (!auth && !this.loggedIn(basics)) {
      return this.unauthorizedError(basics);
    } else if (!auth) {
      return this.forbiddenError(basics);
    }

    const isForm = /multipart/i.test(basics.request.headers['content-type']);
    const qry = () => {
      if (basics.request.originalUrl.indexOf('?') > -1) {
        return [basics.request.query];
      } else {
        const args = [];
        let arg;
        for (let char of 'abcdefghijklm'.split('')) {
          arg = basics.request.params[char];<commit_msg>Additional logging<commit_after>const logger = require('ezzy-logger').logger;
const DEFAULT_CONTENT_TYPE = '*/*';
const {version, name, description} = require('./package');
let inst;

/**
 * Base class that handles a request.
 */
class Request {

  /**
   * Constructor.
   */
  constructor() {
    /**
     * The context in which this request is bound.
     * @type {string|null}
     * @private
     */
    this._context = null;

    /**
     * The custom errors to use when displaying status codes.
     * @type {null|Promise}
     * @private
     */
    this._errors = null;
  }

  /**
   * Flag that could be turned on or off to indicate if we need to send headers.
   * @returns {boolean}
   */
  get sendHeaders() {
    return true;
  }

  /**
   * Default request instance.
   * @returns {Request}
   */
  static get inst() {
    if (!inst) {
      inst = new Request();
    }
    return inst;
  }

  /**
   * The context of the request.
   * @returns {string|null}
   */
  get context() {
    return this._context;
  }

  /**
   * The context of the request.
   * @param {string|null} val The context of the request.
   */
  set context(val) {
    this._context = val;
  }

  /**
   * Handles the request based on method.
   * @param {HttpBasics} basics The HTTP Basics.
   */
  doRequest(basics) {
    const {method, hostname, originalUrl} = basics.request;

    logger.deepDebug('Interception',
      `Request intercepted by ${this.constructor.name}`);

    if (!this.isRequestOk(basics)) {
      return this.requestNotOk(basics);
    } else {
      logger.debug('Request', `${method} ${hostname} ${originalUrl}`);
      logger.deepDebug('Headers', basics.request.headers);
    }

    const auth = this.auth(basics);
    if (!auth && !this.loggedIn(basics)) {
      return this.unauthorizedError(basics);
    } else if (!auth) {
      return this.forbiddenError(basics);
    }

    const isForm = /multipart/i.test(basics.request.headers['content-type']);
    const qry = () => {
      if (basics.request.originalUrl.indexOf('?') > -1) {
        return [basics.request.query];
      } else {
        const args = [];
        let arg;
        for (let char of 'abcdefghijklm'.split('')) {
          arg = basics.request.params[char];
{'fraction_non_alphanumeric': 0.14731839782756279, 'fraction_numerical': 0.00045259108395564606, 'mean_word_length': 2.4210526315789473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2524092', 'n_tokens_mistral': 1412, 'n_tokens_neox': 1383, 'n_words': 365}