"use strict";

/**
 * Constants enumerating the HTTP status codes.
 *
 * All status codes defined in RFC1945 (HTTP/1.0, RFC2616 (HTTP/1.1),
 * and RFC2518 (WebDAV) are supported.
 *
 * Based on the org.apache.commons.httpclient.HttpStatus Java API.
 *
 * Ported by Bryce Neal.
 */

exports.ACCEPTED = 202;
exports.BAD_GATEWAY = 502;
exports.BAD_REQUEST = 400;
exports.CONFLICT = 409;
exports.CONTINUE = 100;
exports.CREATED = 201;
exports.EXPECTATION_FAILED = 417;
exports.FORBIDDEN = 403;
exports.GATEWAY_TIMEOUT = 504;
exports.GONE = 410;
exports.HTTP_VERSION_NOT_SUPPORTED = 505;
exports.INSUFFICIENT_SPACE_ON_RESOURCE = 419;
exports.INSUFFICIENT_STORAGE = 507;
exports.INTERNAL_SERVER_ERROR = 500;
exports.LENGTH_REQUIRED = 411;
exports.LOCKED = 423;
exports.METHOD_FAILURE = 420;
exports.METHOD_NOT_ALLOWED = 405;
exports.MOVED_PERMANENTLY = 301;
exports.MOVED_TEMPORARILY = 302;
exports.MULTI_STATUS = 207;
exports.MULTIPLE_CHOICES = 300;
exports.NO_CONTENT = 204;
exports.NON_AUTHORITATIVE_INFORMATION = 203;
exports.NOT_ACCEPTABLE = 406;
exports.NOT_FOUND = 404;
exports.NOT_IMPLEMENTED = 501;
exports.NOT_MODIFIED = 304;
exports.OK = 200;
exports.PARTIAL_CONTENT = 206;
exports.PAYMENT_REQUIRED = 402;
exports.PRECONDITION_FAILED = 412;
exports.PROCESSING = 102;
exports.PROXY_AUTHENTICATION_REQUIRED = 407;
exports.REQUEST_TIMEOUT = 408;
exports.REQUEST_TOO_LONG = 413;
exports.REQUEST_URI_TOO_LONG = 414;
exports.REQUESTED_RANGE_NOT_SATISFIABLE = 416;
exports.RESET_CONTENT = 205;
exports.SEE_OTHER = 303;
exports.SERVICE_UNAVAILABLE = 503;
exports.SWITCHING_PROTOCOLS = 101;
exports.TEMPORARY_REDIRECT = 307;
exports.UNAUTHORIZED = 401;
exports.UNPROCESSABLE_ENTITY = 422;
exports.UNSUPPORTED_MEDIA_TYPE = 415;
exports.USE_PROXY = 305;
exports.ELASTICSEARCH = 306;
exports.SERVER_UNRESPONSIVE = -1;
exports.ABORTED= 0;
exports.EARLY_HINTS= 103;

var statusCodes = {};

statusCodes[exports.ACCEPTED] = "Accepted";
statusCodes[exports.BAD_GATEWAY] = "Bad Gateway";
statusCodes[exports.BAD_REQUEST] = "Bad Request";
statusCodes[exports.CONFLICT] = "Conflict";
statusCodes[exports.CONTINUE] = "Continue";
statusCodes[exports.CREATED] = "Created";
statusCodes[exports.EXPECTATION_FAILED] = "Expectation Failed";
statusCodes[exports.FORBIDDEN] = "Forbidden";
statusCodes[exports.GATEWAY_TIMEOUT] = "Gateway Timeout";
statusCodes[exports.GONE] = "Gone";
statusCodes[exports.HTTP_VERSION_NOT_SUPPORTED] = "HTTP Version Not Supported";
statusCodes[exports.INSUFFICIENT_SPACE_ON_RESOURCE] = "Insufficient Space on Resource";
statusCodes[exports.INSUFFICIENT_STORAGE] = "Insufficient Storage";
statusCodes[exports.INTERNAL_SERVER_ERROR] = "Server Error";
statusCodes[exports.LENGTH_REQUIRED] = "Length Required";
statusCodes[exports.LOCKED] = "Locked";
statusCodes[exports.METHOD_FAILURE] = "Method Failure";
statusCodes[exports.METHOD_NOT_ALLOWED] = "Method Not Allowed";
statusCodes[exports.MOVED_PERMANENTLY] = "Moved Permanently";
statusCodes[exports.MOVED_TEMPORARILY] = "Moved Temporarily";
statusCodes[exports.MULTI_STATUS] = "Multi-Status";
statusCodes[exports.MULTIPLE_CHOICES] = "Multiple Choices";
statusCodes[exports.NO_CONTENT] = "No Content";
statusCodes[exports.NON_AUTHORITATIVE_INFORMATION] = "Non Authoritative Information";
statusCodes[exports.NOT_ACCEPTABLE] = "Not Acceptable";
statusCodes[exports.NOT_FOUND] = "Not Found";
statusCodes[exports.NOT_IMPLEMENTED] = "Not Implemented";
statusCodes[exports.NOT_MODIFIED] = "Not Modified";
statusCodes[exports.OK] = "OK";
statusCodes[exports.PARTIAL_CONTENT] = "Partial Content";
statusCodes[exports.PAYMENT_REQUIRED] = "Payment Required";
statusCodes[exports.PRECONDITION_FAILED] = "Precondition Failed";
statusCodes[exports.PROCESSING] = "Processing";
statusCodes[exports.PROXY_AUTHENTICATION_REQUIRED] = "Proxy Authentication Required";
statusCodes[exports.REQUEST_TIMEOUT] = "Request Timeout";
statusCodes[exports.REQUEST_TOO_LONG] = "Request Entity Too Large";
statusCodes[exports.REQUEST_URI_TOO_LONG] = "Request-URI Too Long";
statusCodes[exports.REQUESTED_RANGE_NOT_SATISFIABLE] = "Requested Range Not Satisfiable";
statusCodes[exports.RESET_CONTENT] = "Reset Content";
statusCodes[exports.SEE_OTHER] = "See Other";
statusCodes[exports.SERVICE_UNAVAILABLE] = "Service Unavailable";
statusCodes[exports.SWITCHING_PROTOCOLS] = "Switching Protocols";
statusCodes[exports.TEMPORARY_REDIRECT] = "Temporary Redirect";
statusCodes[exports.UNAUTHORIZED] = "Unauthorized";
statusCodes[exports.UNPROCESSABLE_ENTITY] = "Unprocessable Entity";
statusCodes[exports.UNSUPPORTED_MEDIA_TYPE] = "Unsupported Media Type";
statusCodes[exports.USE_PROXY] = "Use Proxy";
statusCodes[exports.ELASTICSEARCH] = "Error - search is not running. Please contact a system administrator to configure it";
statusCodes[exports.SERVER_UNRESPONSIVE] = "Aborted/Timed out request: Server is down or client not connected.";
statusCodes[exports.ABORTED] = "Aborted";
statusCodes[exports.EARLY_HINTS] = "Early Hints";

exports.getStatusText = function(statusCode) {
  if (statusCodes.hasOwnProperty(statusCode)) {
    return statusCodes[statusCode];
  } else {
    return `Unknown status ${statusCode}`;
  }
};
