-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrew Sumner
committed
Oct 30, 2016
1 parent
e2faf51
commit 4d27fda
Showing
14 changed files
with
998 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.inedo.http; | ||
|
||
/** | ||
* An enumeration representing the class of an http response status code. | ||
*/ | ||
public enum Family { | ||
|
||
/** | ||
* {@code 1xx} HTTP status codes. | ||
*/ | ||
INFORMATIONAL, | ||
/** | ||
* {@code 2xx} HTTP status codes. | ||
*/ | ||
SUCCESSFUL, | ||
/** | ||
* {@code 3xx} HTTP status codes. | ||
*/ | ||
REDIRECTION, | ||
/** | ||
* {@code 4xx} HTTP status codes. | ||
*/ | ||
CLIENT_ERROR, | ||
/** | ||
* {@code 5xx} HTTP status codes. | ||
*/ | ||
SERVER_ERROR, | ||
/** | ||
* Other, unrecognized HTTP status codes. | ||
*/ | ||
OTHER; | ||
|
||
/** | ||
* Get the response status family for the status code. | ||
* | ||
* @param statusCode response status code to get the family for. | ||
* @return family of the response status code. | ||
*/ | ||
public static Family familyOf(final int statusCode) { | ||
switch (statusCode / 100) { | ||
case 1: | ||
return Family.INFORMATIONAL; | ||
case 2: | ||
return Family.SUCCESSFUL; | ||
case 3: | ||
return Family.REDIRECTION; | ||
case 4: | ||
return Family.CLIENT_ERROR; | ||
case 5: | ||
return Family.SERVER_ERROR; | ||
default: | ||
return Family.OTHER; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.