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