Skip to content

Commit a2a5a12

Browse files
committed
feat: implement detailed mapping for HTTP status codes in from_int function
1 parent 783c195 commit a2a5a12

1 file changed

Lines changed: 65 additions & 1 deletion

File tree

status_code.mbt

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,71 @@ pub(all) enum StatusCode {
131131

132132
///|
133133
pub fn StatusCode::from_int(i : Int) -> StatusCode {
134-
Custom(i)
134+
match i {
135+
100 => Continue
136+
101 => SwitchingProtocols
137+
102 => Processing
138+
103 => EarlyHints
139+
200 => OK
140+
201 => Created
141+
202 => Accepted
142+
203 => NonAuthoritativeInfo
143+
204 => NoContent
144+
205 => ResetContent
145+
206 => PartialContent
146+
207 => MultiStatus
147+
208 => AlreadyReported
148+
226 => IMUsed
149+
300 => MultipleChoices
150+
301 => MovedPermanently
151+
302 => Found
152+
303 => SeeOther
153+
304 => NotModified
154+
305 => UseProxy
155+
307 => TemporaryRedirect
156+
308 => PermanentRedirect
157+
400 => BadRequest
158+
401 => Unauthorized
159+
402 => PaymentRequired
160+
403 => Forbidden
161+
404 => NotFound
162+
405 => MethodNotAllowed
163+
406 => NotAcceptable
164+
407 => ProxyAuthRequired
165+
408 => RequestTimeout
166+
409 => Conflict
167+
410 => Gone
168+
411 => LengthRequired
169+
412 => PreconditionFailed
170+
413 => RequestEntityTooLarge
171+
414 => RequestUriTooLong
172+
415 => UnsupportedMediaType
173+
416 => RequestedRangeNotSatisfiable
174+
417 => ExpectationFailed
175+
418 => Teapot
176+
421 => MisdirectedRequest
177+
422 => UnprocessableEntity
178+
423 => Locked
179+
424 => FailedDependency
180+
425 => TooEarly
181+
426 => UpgradeRequired
182+
428 => PreconditionRequired
183+
429 => TooManyRequests
184+
431 => RequestHeaderFieldsTooLarge
185+
451 => UnavailableForLegalReasons
186+
500 => InternalServerError
187+
501 => NotImplemented
188+
502 => BadGateway
189+
503 => ServiceUnavailable
190+
504 => GatewayTimeout
191+
505 => HttpVersionNotSupported
192+
506 => VariantAlsoNegotiates
193+
507 => InsufficientStorage
194+
508 => LoopDetected
195+
510 => NotExtended
196+
511 => NetworkAuthenticationRequired
197+
_ => Custom(i)
198+
}
135199
}
136200

137201
///|

0 commit comments

Comments
 (0)