<commit_before>import ns from 'imajs/client/core/namespace.js';

ns.namespace('Core.Router');

/**
 * Wrapper for the ExpressJS request, exposing only the neccessary minimum.
 *
 * @class Request
 * @namespace Core.Router
 * @module Core
 * @submodule Core.Router
 */
export default class Request {

	/**
	 * Initializes the request.
	 *
	 * @constructor
	 * @method constructor
	 */
	constructor() {

		/**
		 * The current ExpressJS request object, or {@code null} if running at the
		 * client side.
		 *
		 * @private
		 * @property _request
		 * @type {?Express.Request}
		 * @default null
		 */
		this._request = null;
	}

	/**
	 * Initializes the request using the provided ExpressJS request object.
	 *
	 * @method init
	 * @param {?Express.Request} request The ExpressJS request object
	 *        representing the current request. Use {@code null} at the client
	 *        side.
	 */
	init(request) {
		this._request = request;
	}

	/**
	 * Returns the path part of the URL to which the request was made.
	 *
	 * @method getPath
	 * @return {string} The path to which the request was made.
	 */
	getPath() {
		return this._request ? this._request.originalUrl : '';
	}

	/**
	 * Returns the {@code Cookie} HTTP header value.
	 *
	 * @method getCookieHeader
	 * @return {string} The value of the {@code Cookie} header.
	 */
	getCookieHeader() {
		return this._request ? this._request.get('Cookie') : '';
	}

	/**
	 * Returns uploaded file to server and meta information.
	 *
	 * @method getFile
	 * @return {Object<string, *>|null}
	 */
	getFile() {
		return this._request ? this._request.file : null;
	}

	/**
	 * Returns upaloaded files to server with their meta information.
	 *
	 * @method getFiles
	 * @return {Object<string, *>|null}
	 */
	getFiles() {
		return this._request ? this._request.files : null;
	}

	/**
	 * Returns body of request.
	 *
	 * @method getBody
	 * @return {string|null}
	 */
	getBody() {
		return this._request ? this._request.body : null;
	}
}

ns.Core.Router.Request = Request;<commit_msg>#! add methods getHeader, getIP and getIPs<commit_after>import ns from 'imajs/client/core/namespace.js';

ns.namespace('Core.Router');

/**
 * Wrapper for the ExpressJS request, exposing only the neccessary minimum.
 *
 * @class Request
 * @namespace Core.Router
 * @module Core
 * @submodule Core.Router
 */
export default class Request {

	/**
	 * Initializes the request.
	 *
	 * @constructor
	 * @method constructor
	 */
	constructor() {

		/**
		 * The current ExpressJS request object, or {@code null} if running at the
		 * client side.
		 *
		 * @private
		 * @property _request
		 * @type {?Express.Request}
		 * @default null
		 */
		this._request = null;
	}

	/**
	 * Initializes the request using the provided ExpressJS request object.
	 *
	 * @method init
	 * @param {?Express.Request} request The ExpressJS request object
	 *        representing the current request. Use {@code null} at the client
	 *        side.
	 */
	init(request) {
		this._request = request;
	}

	/**
	 * Returns the path part of the URL to which the request was made.
	 *
	 * @method getPath
	 * @return {string} The path to which the request was made.
	 */
	getPath() {
		return this._request ? this._request.originalUrl : '';
	}

	/**
	 * Returns the {@code Cookie} HTTP header value.
	 *
	 * @method getCookieHeader
	 * @return {string} The value of the {@code Cookie} header.
	 */
	getCookieHeader() {
		return this._request ? this._request.get('Cookie') : '';
	}

	/**
	 * Returns uploaded file to server and meta information.
	 *
	 * @method getFile
	 * @return {(Object<string, *>|null)}
	 */
	getFile() {
		return this._request ? this._request.file : null;
	}

	/**
	 * Returns upaloaded files to server with their meta information.
	 *
	 * @method getFiles
	 * @return {(Object<string, *>|null)}
	 */
	getFiles() {
		return this._request ? this._request.files : null;
	}

	/**
	 * Returns body of request.
	 *
	 * @method getBody
	 * @return {(string|null)}
	 */
	getBody() {
		return this._request ? this._request.body || null : null;
	}

	/**
	 * Returns the specified HTTP request header.
	 *
	 * @method getHeader
	 * @param {string} header
	 * @return {(string|null)}
	 */
	getHeader(header) {
		return this._request ? this._request.get(header) || null : null;
	}

	/**
	 * Returns the remote IP address of the request.
	 *
	 * @method getIP
	 * @return {(string|null)}
	 */
	getIP() {
		return this._request ? this._request.ip : null;
	}

	/**
	 * Returns array of IP addresses specified in the “X-Forwarded-For”
	 * request header.
	 *
	 * @method getIPs
	 * @return {Array<string>}
	 */
	getIPs() {
		return this._request ? this._request.ips : [];
	}
}

ns.Core.Router.Request = Request;
{'fraction_non_alphanumeric': 0.13435049798686163, 'fraction_numerical': 0.0, 'mean_word_length': 2.959731543624161, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '4796924', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1411, 'n_words': 445}