vibe.http.status 0/62(0%) line coverage

      
10
20
30
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
350
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
570
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
880
890
900
910
920
930
940
950
960
970
980
990
1000
1010
1020
1030
1040
1050
1060
1070
1080
1090
1100
1110
1120
1130
1140
1150
1160
1170
1180
1190
1200
1210
1220
1230
1240
1250
1260
1270
1280
1290
1300
1310
1320
1330
1340
1350
1360
1370
1380
1390
1400
1410
1420
1430
1440
1450
1460
1470
1480
1490
1500
1510
1520
1530
1540
1550
1560
1570
1580
1590
1600
1610
1620
1630
1640
1650
1660
1670
1680
1690
1700
1710
1720
1730
1740
1750
1760
1770
1780
1790
1800
1810
1820
1830
1840
1850
1860
1870
1880
1890
1900
1910
1920
1930
1940
/** List of all standard HTTP status codes. Copyright: © 2012 RejectedSoftware e.K. License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. Authors: Jan Krüger */ module vibe.http.status; /** Definitions of all standard HTTP status codes. */ enum HTTPStatus { continue_ = 100, switchingProtocols = 101, ok = 200, created = 201, accepted = 202, nonAuthoritativeInformation = 203, noContent = 204, resetContent = 205, partialContent = 206, multipleChoices = 300, movedPermanently = 301, found = 302, seeOther = 303, notModified = 304, useProxy = 305, temporaryRedirect = 307, badRequest = 400, unauthorized = 401, paymentRequired = 402, forbidden = 403, notFound = 404, methodNotAllowed = 405, notAcceptable = 406, proxyAuthenticationRequired = 407, requestTimeout = 408, conflict = 409, gone = 410, lengthRequired = 411, preconditionFailed = 412, requestEntityTooLarge = 413, requestURITooLarge = 414, unsupportedMediaType = 415, requestedrangenotsatisfiable = 416, expectationFailed = 417, tooManyRequests = 429, unavailableForLegalReasons = 451, internalServerError = 500, notImplemented = 501, badGateway = 502, serviceUnavailable = 503, gatewayTimeout = 504, httpVersionNotSupported = 505, // WebDAV status codes multiStatus = 207, unprocessableEntity = 422, locked = 423, failedDependency = 424, insufficientStorage = 507, Continue = continue_, /// deprecated SwitchingProtocols = switchingProtocols, /// deprecated OK = ok, /// deprecated Created = created, /// deprecated Accepted = accepted, /// deprecated NonAuthoritativeInformation = nonAuthoritativeInformation, /// deprecated NoContent = noContent, /// deprecated ResetContent = resetContent, /// deprecated PartialContent = partialContent, /// deprecated MultipleChoices = multipleChoices, /// deprecated MovedPermanently = movedPermanently, /// deprecated Found = found, /// deprecated SeeOther = seeOther, /// deprecated NotModified = notModified, /// deprecated UseProxy = useProxy, /// deprecated TemporaryRedirect = temporaryRedirect, /// deprecated BadRequest = badRequest, /// deprecated Unauthorized = unauthorized, /// deprecated PaymentRequired = paymentRequired, /// deprecated Forbidden = forbidden, /// deprecated NotFound = notFound, /// deprecated MethodNotAllowed = methodNotAllowed, /// deprecated NotAcceptable = notAcceptable, /// deprecated ProxyAuthenticationRequired = proxyAuthenticationRequired, /// deprecated RequestTimeout = requestTimeout, /// deprecated Conflict = conflict, /// deprecated Gone = gone, /// deprecated LengthRequired = lengthRequired, /// deprecated PreconditionFailed = preconditionFailed, /// deprecated RequestEntityTooLarge = requestEntityTooLarge, /// deprecated RequestURITooLarge = requestURITooLarge, /// deprecated UnsupportedMediaType = unsupportedMediaType, /// deprecated Requestedrangenotsatisfiable = requestedrangenotsatisfiable, /// deprecated ExpectationFailed = expectationFailed, /// deprecated InternalServerError = internalServerError, /// deprecated NotImplemented = notImplemented, /// deprecated BadGateway = badGateway, /// deprecated ServiceUnavailable = serviceUnavailable, /// deprecated GatewayTimeout = gatewayTimeout, /// deprecated HTTPVersionNotSupported = httpVersionNotSupported, /// deprecated } @safe nothrow @nogc pure: /** Returns a standard text description of the specified HTTP status code. */ string httpStatusText(int code) { switch(code) { default: break; case HTTPStatus.continue_ : return "Continue"; case HTTPStatus.switchingProtocols : return "Switching Protocols"; case HTTPStatus.ok : return "OK"; case HTTPStatus.created : return "Created"; case HTTPStatus.accepted : return "Accepted"; case HTTPStatus.nonAuthoritativeInformation : return "Non-Authoritative Information"; case HTTPStatus.noContent : return "No Content"; case HTTPStatus.resetContent : return "Reset Content"; case HTTPStatus.partialContent : return "Partial Content"; case HTTPStatus.multipleChoices : return "Multiple Choices"; case HTTPStatus.movedPermanently : return "Moved Permanently"; case HTTPStatus.found : return "Found"; case HTTPStatus.seeOther : return "See Other"; case HTTPStatus.notModified : return "Not Modified"; case HTTPStatus.useProxy : return "Use Proxy"; case HTTPStatus.temporaryRedirect : return "Temporary Redirect"; case HTTPStatus.badRequest : return "Bad Request"; case HTTPStatus.unauthorized : return "Unauthorized"; case HTTPStatus.paymentRequired : return "Payment Required"; case HTTPStatus.forbidden : return "Forbidden"; case HTTPStatus.notFound : return "Not Found"; case HTTPStatus.methodNotAllowed : return "Method Not Allowed"; case HTTPStatus.notAcceptable : return "Not Acceptable"; case HTTPStatus.proxyAuthenticationRequired : return "Proxy Authentication Required"; case HTTPStatus.requestTimeout : return "Request Time-out"; case HTTPStatus.conflict : return "Conflict"; case HTTPStatus.gone : return "Gone"; case HTTPStatus.lengthRequired : return "Length Required"; case HTTPStatus.preconditionFailed : return "Precondition Failed"; case HTTPStatus.requestEntityTooLarge : return "Request Entity Too Large"; case HTTPStatus.requestURITooLarge : return "Request-URI Too Large"; case HTTPStatus.unsupportedMediaType : return "Unsupported Media Type"; case HTTPStatus.requestedrangenotsatisfiable : return "Requested range not satisfiable"; case HTTPStatus.expectationFailed : return "Expectation Failed"; case HTTPStatus.unavailableForLegalReasons : return "Unavailable For Legal Reasons"; case HTTPStatus.internalServerError : return "Internal Server Error"; case HTTPStatus.notImplemented : return "Not Implemented"; case HTTPStatus.badGateway : return "Bad Gateway"; case HTTPStatus.serviceUnavailable : return "Service Unavailable"; case HTTPStatus.gatewayTimeout : return "Gateway Time-out"; case HTTPStatus.httpVersionNotSupported : return "HTTP Version not supported"; // WebDAV case HTTPStatus.multiStatus : return "Multi-Status"; case HTTPStatus.unprocessableEntity : return "Unprocessable Entity"; case HTTPStatus.locked : return "Locked"; case HTTPStatus.failedDependency : return "Failed Dependency"; case HTTPStatus.insufficientStorage : return "Insufficient Storage"; } if( code >= 600 ) return "Unknown"; if( code >= 500 ) return "Unknown server error"; if( code >= 400 ) return "Unknown error"; if( code >= 300 ) return "Unknown redirection"; if( code >= 200 ) return "Unknown success"; if( code >= 100 ) return "Unknown information"; return "Unknown"; } /** Determines if the given status code justifies closing the connection (e.g. evil big request bodies) */ bool justifiesConnectionClose(int status) { switch(status) { default: return false; case HTTPStatus.requestEntityTooLarge: case HTTPStatus.requestURITooLarge: case HTTPStatus.requestTimeout: return true; } } /** Determines if status code is generally successful (>= 200 && < 300) */ bool isSuccessCode(HTTPStatus status) { return status >= 200 && status < 300; }