Permalink
Browse files

Fix naming conventions for constants and convert status codes from st…

…ring to number.
  • Loading branch information...
1 parent d292d29 commit 1a23ec5e25c0c7ca6ea7f4ecede74ca99f0e3e4a @gasi gasi committed Apr 18, 2011
Showing with 197 additions and 135 deletions.
  1. +0 −135 index.js
  2. +82 −0 lib/index.js
  3. +115 −0 src/index.coffee
View
@@ -1,135 +0,0 @@
-
-HttpStatus = {};
-
-// Informational 1xx
-
-HttpStatus['100'] = 'Continue';
-HttpStatus.Continue = 200;
-
-HttpStatus['101'] = 'Switching Protocols';
-HttpStatus.SwitchingProtocols = 101;
-
-// Successful 2xx
-
-HttpStatus['200'] = 'OK';
-HttpStatus.OK = 200;
-
-HttpStatus['201'] = 'Created';
-HttpStatus.Created = 201;
-
-HttpStatus['202'] = 'Accepted';
-HttpStatus.Accepted = 202;
-
-HttpStatus['203'] = 'Non-Authoritative Information';
-HttpStatus.NonAuthoritativeInformation = 203;
-
-HttpStatus['204'] = 'No Content';
-HttpStatus.NoContent = 204;
-
-HttpStatus['205'] = 'Reset Content';
-HttpStatus.ResetContent = 205;
-
-HttpStatus['206'] = 'Partial Content';
-HttpStatus.PartialContent = 206;
-
-// Redirection 3xx
-
-HttpStatus['300'] = 'Multiple Choices';
-HttpStatus.MultipleChoices = 300;
-
-HttpStatus['301'] = 'Moved Permanently';
-HttpStatus.MovedPermanently = 301;
-
-HttpStatus['302'] = 'Found';
-HttpStatus.Found = 302;
-
-HttpStatus['303'] = 'See Other';
-HttpStatus.SeeOther = 303;
-
-HttpStatus['304'] = 'Not Modified';
-HttpStatus.NotModified = 304;
-
-HttpStatus['305'] = 'Use Proxy';
-HttpStatus.UseProxy = 305;
-
-HttpStatus['307'] = 'Temporary Redirect';
-HttpStatus.TemporaryRedirect = 307;
-
-// Client Error 4xx
-
-HttpStatus['400'] = 'Bad Request';
-HttpStatus.BadRequest = 400;
-
-HttpStatus['401'] = 'Unauthorized';
-HttpStatus.Unauthorized = 401;
-
-HttpStatus['402'] = 'Payment Required';
-HttpStatus.PaymentRequired = 402;
-
-HttpStatus['403'] = 'Forbidden';
-HttpStatus.Forbidden = 403;
-
-HttpStatus['404'] = 'Not Found';
-HttpStatus.NotFound = 404;
-
-HttpStatus['405'] = 'Method Not Allowed';
-HttpStatus.MethodNotAllowed = 405;
-
-HttpStatus['406'] = 'Not Acceptable';
-HttpStatus.NotAcceptable = 406;
-
-HttpStatus['407'] = 'Proxy Authentication Required';
-HttpStatus.ProxyAuthenticationRequired = 407;
-
-HttpStatus['408'] = 'Request Timeout';
-HttpStatus.RequestTimeout = 408;
-
-HttpStatus['409'] = 'Conflict';
-HttpStatus.Conflict = 409;
-
-HttpStatus['410'] = 'Gone';
-HttpStatus.Gone = 410;
-
-HttpStatus['411'] = 'Length Required';
-HttpStatus.LengthRequired = 411;
-
-HttpStatus['412'] = 'Precondition Failed';
-HttpStatus.PreconditionFailed = 412;
-
-HttpStatus['413'] = 'Request Entity Too Large';
-HttpStatus.RequestEntityTooLarge = 413;
-
-HttpStatus['414'] = 'Request-URI Too Long';
-HttpStatus.RequestURITooLong = 414;
-
-HttpStatus['415'] = 'Unsupported Media Type';
-HttpStatus.UnsupportedMediaType = 415;
-
-HttpStatus['416'] = 'Requested Range Not Satisfiable';
-HttpStatus.RequestedRangeNotSatisfiable = 416;
-
-HttpStatus['417'] = 'Expectation Failed';
-HttpStatus.ExpectationFailed = 417;
-
-// 500 Internal Server Error
-
-HttpStatus['500'] = 'Internal Server Error';
-HttpStatus.InternalServerError = 500;
-
-HttpStatus['501'] = 'Not Implemented';
-HttpStatus.NotImplemented = 501;
-
-HttpStatus['502'] = 'Bad Gateway';
-HttpStatus.BadGateway = 502;
-
-HttpStatus['503'] = 'Service Unavailable';
-HttpStatus.ServiceUnavailable = 503;
-
-HttpStatus['504'] = 'Gateway Timeout';
-HttpStatus.GatewayTimeout = 504;
-
-HttpStatus['505'] = 'HTTP Version Not Supported';
-HttpStatus.HTTPVersionNotSupported = 505;
-
-module.exports = HttpStatus;
-
View
@@ -0,0 +1,82 @@
+module.exports = {
+ 100: 'Continue',
+ 101: 'Switching Protocols',
+ 200: 'OK',
+ 201: 'Created',
+ 202: 'Accepted',
+ 203: 'Non-Authoritative Information',
+ 204: 'No Content',
+ 205: 'Reset Content',
+ 206: 'Partial Content',
+ 300: 'Multiple Choices',
+ 301: 'Moved Permanently',
+ 302: 'Found',
+ 303: 'See Other',
+ 304: 'Not Modified',
+ 305: 'Use Proxy',
+ 307: 'Temporary Redirect',
+ 400: 'Bad Request',
+ 401: 'Unauthorized',
+ 402: 'Payment Required',
+ 403: 'Forbidden',
+ 404: 'Not Found',
+ 405: 'Method Not Allowed',
+ 406: 'Not Acceptable',
+ 407: 'Proxy Authentication Required',
+ 408: 'Request Time-out',
+ 409: 'Conflict',
+ 410: 'Gone',
+ 411: 'Length Required',
+ 412: 'Precondition Failed',
+ 413: 'Request Entity Too Large',
+ 414: 'Request-URI Too Large',
+ 415: 'Unsupported Media Type',
+ 416: 'Requested range not satisfiable',
+ 417: 'Expectation Failed',
+ 500: 'Internal Server Error',
+ 501: 'Not Implemented',
+ 502: 'Bad Gateway',
+ 503: 'Service Unavailable',
+ 504: 'Gateway Time-out',
+ 505: 'HTTP Version not supported',
+ CONTINUE: 100,
+ SWITCHING_PROTOCOLS: 101,
+ OK: 200,
+ CREATED: 201,
+ ACCEPTED: 202,
+ NON_AUTHORITATIVE_INFORMATION: 203,
+ NO_CONTENT: 204,
+ RESET_CONTENT: 205,
+ PARTIAL_CONTENT: 206,
+ MULTITPLE_CHOICES: 300,
+ MOVED_PERMAMENTLY: 301,
+ FOUND: 302,
+ SEE_OTHER: 303,
+ NOT_MODIFIED: 304,
+ USE_PROXY: 305,
+ TEMPORARY_REDIRECT: 307,
+ BAD_REQUEST: 400,
+ UNAUTHORIZED: 401,
+ PAYMENT_REQUIRED: 402,
+ FORBIDDEN: 403,
+ NOT_FOUND: 404,
+ METHOD_NOT_ALLOWED: 405,
+ NOT_ACCEPTABLE: 406,
+ PROXY_AUTHENTICATION_REQUIRED: 407,
+ REQUEST_TIMEOUT: 408,
+ CONFLICT: 409,
+ GONE: 410,
+ LENGTH_REQUIRED: 411,
+ PRECONDITION_FAILED: 412,
+ REQUEST_ENTITY_TOO_LARGE: 413,
+ REQUEST_URI_TOO_LONG: 414,
+ UNSUPPORTED_MEDIA_TYPE: 415,
+ REQUESTED_RANGE_NOT_SATISFIABLE: 416,
+ EXPECTATION_FAILED: 417,
+ INTERNAL_SERVER_ERROR: 500,
+ NOT_IMPLEMENTED: 501,
+ BAD_GATEWAY: 502,
+ SERVICE_UNAVAILABLE: 503,
+ GATEWAY_TIMEOUT: 504,
+ HTTP_VERSION_NOT_SUPPORTED: 505
+};
View
@@ -0,0 +1,115 @@
+# Reference:
+# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
+# http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1
+
+module.exports =
+ # Informational 1xx
+ # Request received, continuing process
+ 100: 'Continue'
+ 101: 'Switching Protocols'
+
+ # Successful 2xx
+ # The action was successfully received, understood, and accepted
+ 200: 'OK'
+ 201: 'Created'
+ 202: 'Accepted'
+ 203: 'Non-Authoritative Information'
+ 204: 'No Content'
+ 205: 'Reset Content'
+ 206: 'Partial Content'
+
+ # Redirection 3xx
+ # Further action must be taken in order to complete the request
+ 300: 'Multiple Choices'
+ 301: 'Moved Permanently'
+ 302: 'Found'
+ 303: 'See Other'
+ 304: 'Not Modified'
+ 305: 'Use Proxy'
+ 307: 'Temporary Redirect'
+
+ # Client Error 4xx
+ # The request contains bad syntax or cannot be fulfilled
+ 400: 'Bad Request'
+ 401: 'Unauthorized'
+ 402: 'Payment Required'
+ 403: 'Forbidden'
+ 404: 'Not Found'
+ 405: 'Method Not Allowed'
+ 406: 'Not Acceptable'
+ 407: 'Proxy Authentication Required'
+ 408: 'Request Time-out'
+ 409: 'Conflict'
+ 410: 'Gone'
+ 411: 'Length Required'
+ 412: 'Precondition Failed'
+ 413: 'Request Entity Too Large'
+ 414: 'Request-URI Too Large'
+ 415: 'Unsupported Media Type'
+ 416: 'Requested range not satisfiable'
+ 417: 'Expectation Failed'
+
+ # Server Error 5xx
+ # The server failed to fulfill an apparently valid request
+ 500: 'Internal Server Error'
+ 501: 'Not Implemented'
+ 502: 'Bad Gateway'
+ 503: 'Service Unavailable'
+ 504: 'Gateway Time-out'
+ 505: 'HTTP Version not supported'
+
+ # Informational 1xx
+ # Request received, continuing process
+ CONTINUE: 100
+ SWITCHING_PROTOCOLS: 101
+
+ # Successful 2xx
+ # The action was successfully received, understood, and accepted
+ OK: 200
+ CREATED: 201
+ ACCEPTED: 202
+ NON_AUTHORITATIVE_INFORMATION: 203
+ NO_CONTENT: 204
+ RESET_CONTENT: 205
+ PARTIAL_CONTENT: 206
+
+ # Redirection 3xx
+ # Further action must be taken in order to complete the request
+ MULTITPLE_CHOICES: 300
+ MOVED_PERMAMENTLY: 301
+ FOUND: 302
+ SEE_OTHER: 303
+ NOT_MODIFIED: 304
+ USE_PROXY: 305
+ # Unused: 306 (reserved)
+ TEMPORARY_REDIRECT: 307
+
+ # Client Error 4xx
+ # The request contains bad syntax or cannot be fulfilled
+ BAD_REQUEST: 400
+ UNAUTHORIZED: 401
+ PAYMENT_REQUIRED: 402
+ FORBIDDEN: 403
+ NOT_FOUND: 404
+ METHOD_NOT_ALLOWED: 405
+ NOT_ACCEPTABLE: 406
+ PROXY_AUTHENTICATION_REQUIRED: 407
+ REQUEST_TIMEOUT: 408
+ CONFLICT: 409
+ GONE: 410
+ LENGTH_REQUIRED: 411
+ PRECONDITION_FAILED: 412
+ REQUEST_ENTITY_TOO_LARGE: 413
+ REQUEST_URI_TOO_LONG: 414
+ UNSUPPORTED_MEDIA_TYPE: 415
+ REQUESTED_RANGE_NOT_SATISFIABLE: 416
+ EXPECTATION_FAILED: 417
+
+ # Server Error 5xx
+ # The server failed to fulfill an apparently valid request
+ INTERNAL_SERVER_ERROR: 500
+ NOT_IMPLEMENTED: 501
+ BAD_GATEWAY: 502
+ SERVICE_UNAVAILABLE: 503
+ GATEWAY_TIMEOUT: 504
+ HTTP_VERSION_NOT_SUPPORTED: 505

0 comments on commit 1a23ec5

Please sign in to comment.