■ ■ ■ ■ ■ ■
common/src/main/java/com/google/tsunami/common/net/http/HttpStatus.java
| skipped 19 lines |
20 | 20 | | import com.google.common.collect.ImmutableMap; |
21 | 21 | | import java.util.Arrays; |
22 | 22 | | import java.util.function.Function; |
23 | | - | import javax.annotation.Nullable; |
24 | 23 | | |
25 | 24 | | /** |
26 | 25 | | * HTTP Status Codes defined in RFC 2616, RFC 6585, RFC 4918 and RFC 7538. |
| skipped 8 lines |
35 | 34 | | * target="_top">https://tools.ietf.org/html/rfc7538</a> |
36 | 35 | | */ |
37 | 36 | | public enum HttpStatus { |
| 37 | + | // Default |
| 38 | + | HTTP_STATUS_UNSPECIFIED(0, "Status Unspecified"), |
38 | 39 | | |
39 | 40 | | // Informational 1xx |
40 | 41 | | CONTINUE(100, "Continue"), |
| skipped 74 lines |
115 | 116 | | * @param code the HTTP status code. |
116 | 117 | | * @return the matching {@link HttpStatus} from the given status code. |
117 | 118 | | */ |
118 | | - | @Nullable |
119 | 119 | | public static HttpStatus fromCode(int code) { |
120 | | - | return BY_CODE.get(code); |
| 120 | + | HttpStatus status = BY_CODE.get(code); |
| 121 | + | return status == null ? HTTP_STATUS_UNSPECIFIED : status; |
121 | 122 | | } |
122 | 123 | | |
123 | 124 | | private final int code; |
| skipped 35 lines |