@@ -298,13 +298,27 @@ macro_rules! status_codes {
298
298
(
299
299
$(
300
300
$( #[ $docs: meta] ) *
301
- ( $num: expr, $konst : ident, $phrase: expr ) ;
301
+ ( $num: expr, $name : ident $ ( aka $alias : ident ) * , $phrase: literal ) ;
302
302
) +
303
303
) => {
304
304
impl StatusCode {
305
+ const fn from_u16_or_panic( num: u16 ) -> Self {
306
+ if num < 100 || 999 < num {
307
+ panic!( )
308
+ }
309
+ Self ( unsafe { NonZeroU16 :: new_unchecked( num) } )
310
+ }
311
+
305
312
$(
306
313
$( #[ $docs] ) *
307
- pub const $konst: StatusCode = StatusCode ( unsafe { NonZeroU16 :: new_unchecked( $num) } ) ;
314
+ pub const $name: StatusCode = StatusCode :: from_u16_or_panic( $num) ;
315
+ $(
316
+ status_codes! {
317
+ @alias $alias = $name;
318
+ concat!( "Alias of [`" , stringify!( $name) ,
319
+ "`](`Self::" , stringify!( $name) , "`)." )
320
+ }
321
+ ) *
308
322
) +
309
323
310
324
}
@@ -317,40 +331,47 @@ macro_rules! status_codes {
317
331
_ => None
318
332
}
319
333
}
334
+ } ;
335
+
336
+ // Work around rustc 1.49 not supporting #[doc = concat!(...)]. With newer
337
+ // rustc this can be inlined.
338
+ ( @alias $alias: ident = $name: ident; $doc: expr) => {
339
+ #[ doc = $doc]
340
+ pub const $alias: StatusCode = StatusCode :: $name;
320
341
}
321
342
}
322
343
323
344
status_codes ! {
324
345
/// 100 Continue
325
- /// [[RFC7231 , Section 6 .2.1](https://tools.ietf .org/html/rfc7231#section-6.2.1 )]
346
+ /// [[RFC9110 , Section 15 .2.1](https://www.rfc-editor .org/rfc/rfc9110#name-100-continue )]
326
347
( 100 , CONTINUE , "Continue" ) ;
327
348
/// 101 Switching Protocols
328
- /// [[RFC7231 , Section 6 .2.2](https://tools.ietf .org/html/rfc7231#section-6.2.2 )]
349
+ /// [[RFC9110 , Section 15 .2.2](https://www.rfc-editor .org/rfc/rfc9110#name-101-switching-protocols )]
329
350
( 101 , SWITCHING_PROTOCOLS , "Switching Protocols" ) ;
330
351
/// 102 Processing
331
352
/// [[RFC2518](https://tools.ietf.org/html/rfc2518)]
332
353
( 102 , PROCESSING , "Processing" ) ;
333
354
334
355
/// 200 OK
335
- /// [[RFC7231 , Section 6 .3.1](https://tools.ietf .org/html/rfc7231#section-6.3.1 )]
356
+ /// [[RFC9110 , Section 15 .3.1](https://www.rfc-editor .org/rfc/rfc9110#name-200-ok )]
336
357
( 200 , OK , "OK" ) ;
337
358
/// 201 Created
338
- /// [[RFC7231 , Section 6 .3.2](https://tools.ietf .org/html/rfc7231#section-6.3.2 )]
359
+ /// [[RFC9110 , Section 15 .3.2](https://www.rfc-editor .org/rfc/rfc9110#name-201-created )]
339
360
( 201 , CREATED , "Created" ) ;
340
361
/// 202 Accepted
341
- /// [[RFC7231 , Section 6 .3.3](https://tools.ietf .org/html/rfc7231#section-6.3.3 )]
362
+ /// [[RFC9110 , Section 15 .3.3](https://www.rfc-editor .org/rfc/rfc9110#name-202-accepted )]
342
363
( 202 , ACCEPTED , "Accepted" ) ;
343
364
/// 203 Non-Authoritative Information
344
- /// [[RFC7231 , Section 6 .3.4](https://tools.ietf .org/html/rfc7231#section-6.3.4 )]
345
- ( 203 , NON_AUTHORITATIVE_INFORMATION , "Non Authoritative Information" ) ;
365
+ /// [[RFC9110 , Section 15 .3.4](https://www.rfc-editor .org/rfc/rfc9110#name-203-non-authoritative-infor )]
366
+ ( 203 , NON_AUTHORITATIVE_INFORMATION , "Non- Authoritative Information" ) ;
346
367
/// 204 No Content
347
- /// [[RFC7231 , Section 6 .3.5](https://tools.ietf .org/html/rfc7231#section-6.3.5 )]
368
+ /// [[RFC9110 , Section 15 .3.5](https://www.rfc-editor .org/rfc/rfc9110#name-204-no-content )]
348
369
( 204 , NO_CONTENT , "No Content" ) ;
349
370
/// 205 Reset Content
350
- /// [[RFC7231 , Section 6 .3.6](https://tools.ietf .org/html/rfc7231#section-6.3.6 )]
371
+ /// [[RFC9110 , Section 15 .3.6](https://www.rfc-editor .org/rfc/rfc9110#name-205-reset-content )]
351
372
( 205 , RESET_CONTENT , "Reset Content" ) ;
352
373
/// 206 Partial Content
353
- /// [[RFC7233 , Section 4.1 ](https://tools.ietf .org/html/rfc7233#section-4.1 )]
374
+ /// [[RFC9110 , Section 15.3.7 ](https://www.rfc-editor .org/rfc/rfc9110#name-206-partial-content )]
354
375
( 206 , PARTIAL_CONTENT , "Partial Content" ) ;
355
376
/// 207 Multi-Status
356
377
/// [[RFC4918](https://tools.ietf.org/html/rfc4918)]
@@ -364,103 +385,106 @@ status_codes! {
364
385
( 226 , IM_USED , "IM Used" ) ;
365
386
366
387
/// 300 Multiple Choices
367
- /// [[RFC7231 , Section 6 .4.1](https://tools.ietf .org/html/rfc7231#section-6.4.1 )]
388
+ /// [[RFC9110 , Section 15 .4.1](https://www.rfc-editor .org/rfc/rfc9110#name-300-multiple-choices )]
368
389
( 300 , MULTIPLE_CHOICES , "Multiple Choices" ) ;
369
390
/// 301 Moved Permanently
370
- /// [[RFC7231 , Section 6 .4.2](https://tools.ietf .org/html/rfc7231#section-6.4.2 )]
391
+ /// [[RFC9110 , Section 15 .4.2](https://www.rfc-editor .org/rfc/rfc9110#name-301-moved-permanently )]
371
392
( 301 , MOVED_PERMANENTLY , "Moved Permanently" ) ;
372
393
/// 302 Found
373
- /// [[RFC7231 , Section 6 .4.3](https://tools.ietf .org/html/rfc7231#section-6.4.3 )]
394
+ /// [[RFC9110 , Section 15 .4.3](https://www.rfc-editor .org/rfc/rfc9110#name-302-found )]
374
395
( 302 , FOUND , "Found" ) ;
375
396
/// 303 See Other
376
- /// [[RFC7231 , Section 6 .4.4](https://tools.ietf .org/html/rfc7231#section-6.4.4 )]
397
+ /// [[RFC9110 , Section 15 .4.4](https://www.rfc-editor .org/rfc/rfc9110#name-303-see-other )]
377
398
( 303 , SEE_OTHER , "See Other" ) ;
378
399
/// 304 Not Modified
379
- /// [[RFC7232 , Section 4.1 ](https://tools.ietf .org/html/rfc7232#section-4.1 )]
400
+ /// [[RFC9110 , Section 15.4.5 ](https://www.rfc-editor .org/rfc/rfc9110#name-304-not-modified )]
380
401
( 304 , NOT_MODIFIED , "Not Modified" ) ;
381
402
/// 305 Use Proxy
382
- /// [[RFC7231 , Section 6 .4.5 ](https://tools.ietf .org/html/rfc7231#section-6.4.5 )]
403
+ /// [[RFC9110 , Section 15 .4.6 ](https://www.rfc-editor .org/rfc/rfc9110#name-305-use-proxy )]
383
404
( 305 , USE_PROXY , "Use Proxy" ) ;
384
405
/// 307 Temporary Redirect
385
- /// [[RFC7231 , Section 6 .4.7 ](https://tools.ietf .org/html/rfc7231#section-6.4.7 )]
406
+ /// [[RFC9110 , Section 15 .4.8 ](https://www.rfc-editor .org/rfc/rfc9110#name-307-temporary-redirect )]
386
407
( 307 , TEMPORARY_REDIRECT , "Temporary Redirect" ) ;
387
408
/// 308 Permanent Redirect
388
- /// [[RFC7238 ](https://tools.ietf .org/html/rfc7238 )]
409
+ /// [[RFC9110, Section 15.4.9 ](https://www.rfc-editor .org/rfc/rfc9110#name-308-permanent-redirect )]
389
410
( 308 , PERMANENT_REDIRECT , "Permanent Redirect" ) ;
390
411
391
412
/// 400 Bad Request
392
- /// [[RFC7231 , Section 6 .5.1](https://tools.ietf .org/html/rfc7231#section-6.5.1 )]
413
+ /// [[RFC9110 , Section 15 .5.1](https://www.rfc-editor .org/rfc/rfc9110#name-400-bad-request )]
393
414
( 400 , BAD_REQUEST , "Bad Request" ) ;
394
415
/// 401 Unauthorized
395
- /// [[RFC7235 , Section 3.1 ](https://tools.ietf .org/html/rfc7235#section-3.1 )]
416
+ /// [[RFC9110 , Section 15.5.2 ](https://www.rfc-editor .org/rfc/rfc9110#name-401-unauthorized )]
396
417
( 401 , UNAUTHORIZED , "Unauthorized" ) ;
397
418
/// 402 Payment Required
398
- /// [[RFC7231 , Section 6 .5.2 ](https://tools.ietf .org/html/rfc7231#section-6.5.2 )]
419
+ /// [[RFC9110 , Section 15 .5.3 ](https://www.rfc-editor .org/rfc/rfc9110#name-402-payment-required )]
399
420
( 402 , PAYMENT_REQUIRED , "Payment Required" ) ;
400
421
/// 403 Forbidden
401
- /// [[RFC7231 , Section 6 .5.3 ](https://tools.ietf .org/html/rfc7231#section-6.5.3 )]
422
+ /// [[RFC9110 , Section 15 .5.4 ](https://www.rfc-editor .org/rfc/rfc9110#name-403-forbidden )]
402
423
( 403 , FORBIDDEN , "Forbidden" ) ;
403
424
/// 404 Not Found
404
- /// [[RFC7231 , Section 6 .5.4 ](https://tools.ietf .org/html/rfc7231#section-6.5.4 )]
425
+ /// [[RFC9110 , Section 15 .5.5 ](https://www.rfc-editor .org/rfc/rfc9110#name-404-not-found )]
405
426
( 404 , NOT_FOUND , "Not Found" ) ;
406
427
/// 405 Method Not Allowed
407
- /// [[RFC7231 , Section 6 .5.5 ](https://tools.ietf .org/html/rfc7231#section-6.5.5 )]
428
+ /// [[RFC9110 , Section 15 .5.6 ](https://www.rfc-editor .org/rfc/rfc9110#name-405-method-not-allowed )]
408
429
( 405 , METHOD_NOT_ALLOWED , "Method Not Allowed" ) ;
409
430
/// 406 Not Acceptable
410
- /// [[RFC7231 , Section 6 .5.6 ](https://tools.ietf .org/html/rfc7231#section-6.5.6 )]
431
+ /// [[RFC9110 , Section 15 .5.7 ](https://www.rfc-editor .org/rfc/rfc9110#name-406-not-acceptable )]
411
432
( 406 , NOT_ACCEPTABLE , "Not Acceptable" ) ;
412
433
/// 407 Proxy Authentication Required
413
- /// [[RFC7235 , Section 3.2 ](https://tools.ietf .org/html/rfc7235#section-3.2 )]
434
+ /// [[RFC9110 , Section 15.5.8 ](https://www.rfc-editor .org/rfc/rfc9110#name-407-proxy-authentication-re )]
414
435
( 407 , PROXY_AUTHENTICATION_REQUIRED , "Proxy Authentication Required" ) ;
415
436
/// 408 Request Timeout
416
- /// [[RFC7231 , Section 6 .5.7 ](https://tools.ietf .org/html/rfc7231#section-6.5.7 )]
437
+ /// [[RFC9110 , Section 15 .5.9 ](https://www.rfc-editor .org/rfc/rfc9110#name-408-request-timeout )]
417
438
( 408 , REQUEST_TIMEOUT , "Request Timeout" ) ;
418
439
/// 409 Conflict
419
- /// [[RFC7231 , Section 6 .5.8 ](https://tools.ietf .org/html/rfc7231#section-6.5.8 )]
440
+ /// [[RFC9110 , Section 15 .5.10 ](https://www.rfc-editor .org/rfc/rfc9110#name-409-conflict )]
420
441
( 409 , CONFLICT , "Conflict" ) ;
421
442
/// 410 Gone
422
- /// [[RFC7231 , Section 6 .5.9 ](https://tools.ietf .org/html/rfc7231#section-6.5.9 )]
443
+ /// [[RFC9110 , Section 15 .5.11 ](https://www.rfc-editor .org/rfc/rfc9110#name-410-gone )]
423
444
( 410 , GONE , "Gone" ) ;
424
445
/// 411 Length Required
425
- /// [[RFC7231 , Section 6 .5.10 ](https://tools.ietf .org/html/rfc7231#section-6.5.10 )]
446
+ /// [[RFC9110 , Section 15 .5.12 ](https://www.rfc-editor .org/rfc/rfc9110#name-411-length-required )]
426
447
( 411 , LENGTH_REQUIRED , "Length Required" ) ;
427
448
/// 412 Precondition Failed
428
- /// [[RFC7232 , Section 4.2 ](https://tools.ietf .org/html/rfc7232#section-4.2 )]
449
+ /// [[RFC9110 , Section 15.5.13 ](https://www.rfc-editor .org/rfc/rfc9110#name-412-precondition-failed )]
429
450
( 412 , PRECONDITION_FAILED , "Precondition Failed" ) ;
430
- /// 413 Payload Too Large
431
- /// [[RFC7231, Section 6.5.11](https://tools.ietf.org/html/rfc7231#section-6.5.11)]
432
- ( 413 , PAYLOAD_TOO_LARGE , "Payload Too Large" ) ;
451
+ /// 413 Content Too Large
452
+ /// [[RFC9110, Section 15.5.14](https://www.rfc-editor.org/rfc/rfc9110#name-413-content-too-large)]
453
+ ///
454
+ /// Prior to RFC9110 phrase for this status was ‘Payload Too Large’.
455
+ ( 413 , CONTENT_TOO_LARGE aka PAYLOAD_TOO_LARGE , "Content Too Large" ) ;
433
456
/// 414 URI Too Long
434
- /// [[RFC7231 , Section 6 .5.12 ](https://tools.ietf .org/html/rfc7231#section-6.5.12 )]
457
+ /// [[RFC9110 , Section 15 .5.15 ](https://www.rfc-editor .org/rfc/rfc9110#name-414-uri-too-long )]
435
458
( 414 , URI_TOO_LONG , "URI Too Long" ) ;
436
459
/// 415 Unsupported Media Type
437
- /// [[RFC7231 , Section 6 .5.13 ](https://tools.ietf .org/html/rfc7231#section-6.5.13 )]
460
+ /// [[RFC9110 , Section 15 .5.16 ](https://www.rfc-editor .org/rfc/rfc9110#name-415-unsupported-media-type )]
438
461
( 415 , UNSUPPORTED_MEDIA_TYPE , "Unsupported Media Type" ) ;
439
462
/// 416 Range Not Satisfiable
440
- /// [[RFC7233 , Section 4.4 ](https://tools.ietf .org/html/rfc7233#section-4.4 )]
463
+ /// [[RFC9110 , Section 15.5.17 ](https://www.rfc-editor .org/rfc/rfc9110#name-416-range-not-satisfiable )]
441
464
( 416 , RANGE_NOT_SATISFIABLE , "Range Not Satisfiable" ) ;
442
465
/// 417 Expectation Failed
443
- /// [[RFC7231 , Section 6 .5.14 ](https://tools.ietf .org/html/rfc7231#section-6.5.14 )]
466
+ /// [[RFC9110 , Section 15 .5.18 ](https://www.rfc-editor .org/rfc/rfc9110#name-417-expectation-failed )]
444
467
( 417 , EXPECTATION_FAILED , "Expectation Failed" ) ;
445
468
/// 418 I'm a teapot
446
469
/// [curiously not registered by IANA but [RFC2324](https://tools.ietf.org/html/rfc2324)]
447
470
( 418 , IM_A_TEAPOT , "I'm a teapot" ) ;
448
471
449
472
/// 421 Misdirected Request
450
- /// [RFC7540 , Section 9.1.2](http ://tools.ietf .org/html/rfc7540#section-9.1.2)
473
+ /// [[RFC9110 , Section 15.5.20](https ://www.rfc-editor .org/rfc/rfc9110#name-421-misdirected-request)]
451
474
( 421 , MISDIRECTED_REQUEST , "Misdirected Request" ) ;
452
- /// 422 Unprocessable Entity
453
- /// [[RFC4918](https://tools.ietf.org/html/rfc4918)]
454
- ( 422 , UNPROCESSABLE_ENTITY , "Unprocessable Entity" ) ;
475
+ /// 422 Unprocessable Content
476
+ /// [[RFC9110, Section 15.5.21](https://www.rfc-editor.org/rfc/rfc9110#name-422-unprocessable-content)]
477
+ ///
478
+ /// Prior to RFC9110 phrase for this status was ‘Unprocessable Entity’.
479
+ ( 422 , UNPROCESSABLE_CONTENT aka UNPROCESSABLE_ENTITY , "Unprocessable Content" ) ;
455
480
/// 423 Locked
456
481
/// [[RFC4918](https://tools.ietf.org/html/rfc4918)]
457
482
( 423 , LOCKED , "Locked" ) ;
458
483
/// 424 Failed Dependency
459
484
/// [[RFC4918](https://tools.ietf.org/html/rfc4918)]
460
485
( 424 , FAILED_DEPENDENCY , "Failed Dependency" ) ;
461
-
462
486
/// 426 Upgrade Required
463
- /// [[RFC7231 , Section 6 .5.15 ](https://tools.ietf .org/html/rfc7231#section-6.5.15 )]
487
+ /// [[RFC9110 , Section 15 .5.22 ](https://www.rfc-editor .org/rfc/rfc9110#name-426-upgrade-required )]
464
488
( 426 , UPGRADE_REQUIRED , "Upgrade Required" ) ;
465
489
466
490
/// 428 Precondition Required
@@ -479,22 +503,22 @@ status_codes! {
479
503
( 451 , UNAVAILABLE_FOR_LEGAL_REASONS , "Unavailable For Legal Reasons" ) ;
480
504
481
505
/// 500 Internal Server Error
482
- /// [[RFC7231 , Section 6 .6.1](https://tools.ietf .org/html/rfc7231#section-6.6.1 )]
506
+ /// [[RFC9110 , Section 15 .6.1](https://www.rfc-editor .org/rfc/rfc9110#name-500-internal-server-error )]
483
507
( 500 , INTERNAL_SERVER_ERROR , "Internal Server Error" ) ;
484
508
/// 501 Not Implemented
485
- /// [[RFC7231 , Section 6 .6.2](https://tools.ietf .org/html/rfc7231#section-6.6.2 )]
509
+ /// [[RFC9110 , Section 15 .6.2](https://www.rfc-editor .org/rfc/rfc9110#name-501-not-implemented )]
486
510
( 501 , NOT_IMPLEMENTED , "Not Implemented" ) ;
487
511
/// 502 Bad Gateway
488
- /// [[RFC7231 , Section 6 .6.3](https://tools.ietf .org/html/rfc7231#section-6.6.3 )]
512
+ /// [[RFC9110 , Section 15 .6.3](https://www.rfc-editor .org/rfc/rfc9110#name-502-bad-gateway )]
489
513
( 502 , BAD_GATEWAY , "Bad Gateway" ) ;
490
514
/// 503 Service Unavailable
491
- /// [[RFC7231 , Section 6 .6.4](https://tools.ietf .org/html/rfc7231#section-6.6.4 )]
515
+ /// [[RFC9110 , Section 15 .6.4](https://www.rfc-editor .org/rfc/rfc9110#name-503-service-unavailable )]
492
516
( 503 , SERVICE_UNAVAILABLE , "Service Unavailable" ) ;
493
517
/// 504 Gateway Timeout
494
- /// [[RFC7231 , Section 6 .6.5](https://tools.ietf .org/html/rfc7231#section-6.6.5 )]
518
+ /// [[RFC9110 , Section 15 .6.5](https://www.rfc-editor .org/rfc/rfc9110#name-504-gateway-timeout )]
495
519
( 504 , GATEWAY_TIMEOUT , "Gateway Timeout" ) ;
496
520
/// 505 HTTP Version Not Supported
497
- /// [[RFC7231 , Section 6 .6.6](https://tools.ietf .org/html/rfc7231#section-6.6.6 )]
521
+ /// [[RFC9110 , Section 15 .6.6](https://www.rfc-editor .org/rfc/rfc9110#name-505-http-version-not-suppor )]
498
522
( 505 , HTTP_VERSION_NOT_SUPPORTED , "HTTP Version Not Supported" ) ;
499
523
/// 506 Variant Also Negotiates
500
524
/// [[RFC2295](https://tools.ietf.org/html/rfc2295)]
0 commit comments