| 1 | package jrw.util; |
| 2 | |
| 3 | import java.util.*; |
| 4 | |
| 5 | public class Http { |
| 6 | public static final java.nio.charset.Charset UTF8 = java.nio.charset.Charset.forName("UTF-8"); |
| 7 | public static final java.nio.charset.Charset LATIN1 = java.nio.charset.Charset.forName("ISO-8859-1"); |
| 8 | public static final java.nio.charset.Charset ASCII = java.nio.charset.Charset.forName("US-ASCII"); |
| 9 | public static final Map<Integer, StatusInfo> statusinfo; |
| 10 | |
| 11 | public static class StatusInfo { |
| 12 | public final String status, message; |
| 13 | public StatusInfo(String status, String message) {this.status = status; this.message = message;} |
| 14 | } |
| 15 | |
| 16 | static { |
| 17 | Map<Integer, StatusInfo> buf = new HashMap<>(); |
| 18 | buf.put(400, new StatusInfo("Bad Request", "Invalid HTTP request.")); |
| 19 | buf.put(401, new StatusInfo("Unauthorized", "Authentication must be provided for the requested resource..")); |
| 20 | buf.put(403, new StatusInfo("Forbidden", "You ar enot authorized for the requested resource.")); |
| 21 | buf.put(404, new StatusInfo("Not Found", "The requested resource was not found.")); |
| 22 | buf.put(405, new StatusInfo("Method Not Allowed", "The request method is not valid or permitted by the requested resource.")); |
| 23 | buf.put(429, new StatusInfo("Too Many Requests", "Your client is sending more frequent requests than are accepted.")); |
| 24 | buf.put(500, new StatusInfo("Server Error", "An internal error occurred.")); |
| 25 | buf.put(501, new StatusInfo("Not Implemented", "The requested functionality has not been implemented.")); |
| 26 | buf.put(503, new StatusInfo("Service Unavailable", "Service is being denied at this time.")); |
| 27 | statusinfo = Collections.unmodifiableMap(buf); |
| 28 | } |
| 29 | } |