Skip to content

Commit 588ba4a

Browse files
committed
Update RFC reference
1 parent d61f34b commit 588ba4a

2 files changed

Lines changed: 34 additions & 5 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
[![GitHub CI](https://github.com/ethauvin/httpstatus/actions/workflows/bld.yml/badge.svg)](https://github.com/ethauvin/httpstatus/actions/workflows/bld.yml)
1313
[![CircleCI](https://circleci.com/gh/ethauvin/HttpStatus/tree/master.svg?style=shield)](https://circleci.com/gh/ethauvin/HttpStatus/tree/master)
1414

15-
A simple library to search for and display information about [HTTP status codes](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
15+
A simple library to search for and display information about [HTTP status codes](https://datatracker.ietf.org/doc/html/rfc7231#section-6.1).
1616

1717
## Table of Contents
1818

@@ -70,7 +70,7 @@ or
7070
<%= Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()) %>
7171
```
7272

73-
would display on a [501 status code](https://www.rfc-editor.org/rfc/rfc9110.html#name-501-not-implemented):
73+
would display on a [501 status code](https://datatracker.ietf.org/doc/html/rfc7231#section-6.6.2):
7474

7575
```console
7676
Not Implemented
@@ -230,7 +230,7 @@ These methods are also available as [static methods](https://ethauvin.github.io/
230230

231231
### Status Code Class
232232

233-
The [StatusCodeClass](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html) can be used to retrieve all status codes in a specific [class](https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes):
233+
The [StatusCodeClass](https://ethauvin.github.io/HttpStatus/net/thauvin/erik/httpstatus/StatusCodeClass.html) can be used to retrieve all status codes in a specific [class](https://datatracker.ietf.org/doc/html/rfc7231#section-6):
234234

235235
```java
236236
var reasons = Reasons.getReasonClass(StatusCodeClass.SERVER_ERROR); // 5xx
@@ -386,7 +386,7 @@ $ java -jar httpstatus-1.1.1.jar
386386
...
387387
```
388388

389-
You can also print status codes by [classes](https://www.rfc-editor.org/rfc/rfc9110.html#name-status-codes):
389+
You can also print status codes by [classes](https://datatracker.ietf.org/doc/html/rfc7231#section-6.1):
390390

391391
```console
392392
$ java -jar httpstatus-1.1.1.jar 2xx

src/main/java/net/thauvin/erik/httpstatus/StatusCodeClass.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,38 @@
5555
* @since 2.0.0
5656
*/
5757
public enum StatusCodeClass {
58-
INFORMATIONAL(1), SUCCESSFUL(2), REDIRECTION(3), CLIENT_ERROR(4),
58+
/**
59+
* Represents HTTP responses with a status code starting with {@code 1}.
60+
*/
61+
INFORMATIONAL(1),
62+
/**
63+
* Represents HTTP responses with a status code starting with {@code 2}.
64+
*/
65+
SUCCESSFUL(2),
66+
/**
67+
* Represents HTTP responses with a status code starting with {@code 3}.
68+
*/
69+
REDIRECTION(3),
70+
/**
71+
* Represents HTTP responses with a status code starting with {@code 4}.
72+
*/
73+
CLIENT_ERROR(4),
74+
/**
75+
* Represents HTTP responses with a status code starting with {@code 5}.
76+
*/
5977
SERVER_ERROR(5);
6078

6179
// Static map for O(1) lookup - initialized once
6280
private static final Map<Integer, StatusCodeClass> LOOKUP_MAP =
6381
Arrays.stream(values()).collect(Collectors.toMap(StatusCodeClass::getFirstDigit, Function.identity()));
6482
private final int firstDigit;
6583

84+
/**
85+
* Constructs a new instance of {@link StatusCodeClass} with the specified first digit.
86+
*
87+
* @param firstDigit The first digit of the HTTP status code class. This value determines the classification of the
88+
* HTTP status codes (e.g., {@code 1} for informational, {@code 2} for successful, etc.)
89+
*/
6690
StatusCodeClass(int firstDigit) {
6791
this.firstDigit = firstDigit;
6892
}
@@ -80,6 +104,11 @@ public static Optional<StatusCodeClass> fromFirstDigit(int firstDigit) {
80104
return Optional.ofNullable(LOOKUP_MAP.get(firstDigit));
81105
}
82106

107+
/**
108+
* Retrieves the first digit representing the classification of HTTP status codes.
109+
*
110+
* @return The first digit of the HTTP status code class.
111+
*/
83112
public int getFirstDigit() {
84113
return firstDigit;
85114
}

0 commit comments

Comments
 (0)