@@ -59,6 +59,97 @@ RKRequestMethod RKRequestMethodFromString(NSString *methodName)
59
59
else return RKRequestMethodInvalid;
60
60
}
61
61
62
+ // Built from http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
63
+ static NSDictionary *RKStatusCodesToNamesDictionary ()
64
+ {
65
+ static NSDictionary *statusCodesToNamesDictionary = nil ;
66
+ static dispatch_once_t onceToken;
67
+ dispatch_once (&onceToken, ^{
68
+ statusCodesToNamesDictionary = @{
69
+ // 1xx (Informational)
70
+ @(100 ): @" Continue" ,
71
+ @(101 ): @" Switching Protocols" ,
72
+ @(102 ): @" Processing" ,
73
+
74
+ // 2xx (Success)
75
+ @(200 ): @" OK" ,
76
+ @(201 ): @" Created" ,
77
+ @(202 ): @" Accepted" ,
78
+ @(203 ): @" Non-Authoritative Information" ,
79
+ @(204 ): @" No Content" ,
80
+ @(205 ): @" Reset Content" ,
81
+ @(206 ): @" Partial Content" ,
82
+ @(207 ): @" Multi-Status" ,
83
+ @(208 ): @" Already Reported" ,
84
+ @(226 ): @" IM Used" ,
85
+
86
+ // 3xx (Redirection)
87
+ @(300 ): @" Multiple Choices" ,
88
+ @(301 ): @" Moved Permanently" ,
89
+ @(302 ): @" Found" ,
90
+ @(303 ): @" See Other" ,
91
+ @(304 ): @" Not Modified" ,
92
+ @(305 ): @" Use Proxy" ,
93
+ @(306 ): @" Switch Proxy" ,
94
+ @(307 ): @" Temporary Redirect" ,
95
+ @(308 ): @" Permanent Redirect" ,
96
+
97
+ // 4xx (Client Error)
98
+ @(400 ): @" Bad Request" ,
99
+ @(401 ): @" Unauthorized" ,
100
+ @(402 ): @" Payment Required" ,
101
+ @(403 ): @" Forbidden" ,
102
+ @(404 ): @" Not Found" ,
103
+ @(405 ): @" Method Not Allowed" ,
104
+ @(406 ): @" Not Acceptable" ,
105
+ @(407 ): @" Proxy Authentication Required" ,
106
+ @(408 ): @" Request Timeout" ,
107
+ @(409 ): @" Conflict" ,
108
+ @(410 ): @" Gone" ,
109
+ @(411 ): @" Length Required" ,
110
+ @(412 ): @" Precondition Failed" ,
111
+ @(413 ): @" Request Entity Too Large" ,
112
+ @(414 ): @" Request-URI Too Long" ,
113
+ @(415 ): @" Unsupported Media Type" ,
114
+ @(416 ): @" Requested Range Not Satisfiable" ,
115
+ @(417 ): @" Expectation Failed" ,
116
+ @(418 ): @" I'm a teapot" ,
117
+ @(420 ): @" Enhance Your Calm" ,
118
+ @(422 ): @" Unprocessable Entity" ,
119
+ @(423 ): @" Locked" ,
120
+ @(424 ): @" Failed Dependency" ,
121
+ @(424 ): @" Method Failure" ,
122
+ @(425 ): @" Unordered Collection" ,
123
+ @(426 ): @" Upgrade Required" ,
124
+ @(428 ): @" Precondition Required" ,
125
+ @(429 ): @" Too Many Requests" ,
126
+ @(431 ): @" Request Header Fields Too Large" ,
127
+ @(451 ): @" Unavailable For Legal Reasons" ,
128
+
129
+ // 5xx (Server Error)
130
+ @(500 ): @" Internal Server Error" ,
131
+ @(501 ): @" Not Implemented" ,
132
+ @(502 ): @" Bad Gateway" ,
133
+ @(503 ): @" Service Unavailable" ,
134
+ @(504 ): @" Gateway Timeout" ,
135
+ @(505 ): @" HTTP Version Not Supported" ,
136
+ @(506 ): @" Variant Also Negotiates" ,
137
+ @(507 ): @" Insufficient Storage" ,
138
+ @(508 ): @" Loop Detected" ,
139
+ @(509 ): @" Bandwidth Limit Exceeded" ,
140
+ @(510 ): @" Not Extended" ,
141
+ @(511 ): @" Network Authentication Required" ,
142
+ };
143
+ });
144
+ return statusCodesToNamesDictionary;
145
+ }
146
+
147
+ NSString * RKStringFromStatusCode (NSInteger statusCode)
148
+ {
149
+ return [RKStatusCodesToNamesDictionary () objectForKey: @(statusCode)];
150
+ }
151
+
152
+
62
153
/* *
63
154
Below is ragel source used to compile those tables. The output was polished / pretty-printed and tweaked from ragel.
64
155
As the generated code is "hard" to debug, we store the code in http-date.r1
0 commit comments