|
| 1 | +/* |
| 2 | + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/HttpStatus.java,v 1.18 2004/05/02 11:21:13 olegk Exp $ |
| 3 | + * $Revision: 480424 $ |
| 4 | + * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $ |
| 5 | + * |
| 6 | + * ==================================================================== |
| 7 | + * |
| 8 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 9 | + * contributor license agreements. See the NOTICE file distributed with |
| 10 | + * this work for additional information regarding copyright ownership. |
| 11 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 12 | + * (the "License"); you may not use this file except in compliance with |
| 13 | + * the License. You may obtain a copy of the License at |
| 14 | + * |
| 15 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | + * |
| 17 | + * Unless required by applicable law or agreed to in writing, software |
| 18 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 19 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 20 | + * See the License for the specific language governing permissions and |
| 21 | + * limitations under the License. |
| 22 | + * ==================================================================== |
| 23 | + * |
| 24 | + * This software consists of voluntary contributions made by many |
| 25 | + * individuals on behalf of the Apache Software Foundation. For more |
| 26 | + * information on the Apache Software Foundation, please see |
| 27 | + * <http://www.apache.org/>. |
| 28 | + * |
| 29 | + */ |
| 30 | +package org.openapitools.openapidiff.core.output; |
| 31 | + |
| 32 | +import java.util.HashMap; |
| 33 | +import java.util.Map; |
| 34 | + |
| 35 | +/** |
| 36 | + * Constants enumerating the HTTP status codes. All status codes defined in RFC1945 (HTTP/1.0, |
| 37 | + * RFC2616 (HTTP/1.1), and RFC2518 (WebDAV) are supported. |
| 38 | + */ |
| 39 | +public final class HttpStatus { |
| 40 | + |
| 41 | + private static final Map<Integer, String> REASON_PHRASES = new HashMap<>(); |
| 42 | + |
| 43 | + static { |
| 44 | + REASON_PHRASES.put(100, "Continue"); |
| 45 | + REASON_PHRASES.put(101, "Switching Protocols"); |
| 46 | + REASON_PHRASES.put(102, "Processing"); |
| 47 | + REASON_PHRASES.put(200, "OK"); |
| 48 | + REASON_PHRASES.put(201, "Created"); |
| 49 | + REASON_PHRASES.put(202, "Accepted"); |
| 50 | + REASON_PHRASES.put(203, "Non Authoritative Information"); |
| 51 | + REASON_PHRASES.put(204, "No Content"); |
| 52 | + REASON_PHRASES.put(205, "Reset Content"); |
| 53 | + REASON_PHRASES.put(206, "Partial Content"); |
| 54 | + REASON_PHRASES.put(207, "Multi-Status"); |
| 55 | + REASON_PHRASES.put(300, "Multiple Choices"); |
| 56 | + REASON_PHRASES.put(301, "Moved Permanently"); |
| 57 | + REASON_PHRASES.put(302, "Moved Temporarily"); |
| 58 | + REASON_PHRASES.put(303, "See Other"); |
| 59 | + REASON_PHRASES.put(304, "Not Modified"); |
| 60 | + REASON_PHRASES.put(305, "Use Proxy"); |
| 61 | + REASON_PHRASES.put(307, "Temporary Redirect"); |
| 62 | + REASON_PHRASES.put(400, "Bad Request"); |
| 63 | + REASON_PHRASES.put(401, "Unauthorized"); |
| 64 | + REASON_PHRASES.put(402, "Payment Required"); |
| 65 | + REASON_PHRASES.put(403, "Forbidden"); |
| 66 | + REASON_PHRASES.put(404, "Not Found"); |
| 67 | + REASON_PHRASES.put(405, "Method Not Allowed"); |
| 68 | + REASON_PHRASES.put(406, "Not Acceptable"); |
| 69 | + REASON_PHRASES.put(407, "Proxy Authentication Required"); |
| 70 | + REASON_PHRASES.put(408, "Request Timeout"); |
| 71 | + REASON_PHRASES.put(409, "Conflict"); |
| 72 | + REASON_PHRASES.put(410, "Gone"); |
| 73 | + REASON_PHRASES.put(411, "Length Required"); |
| 74 | + REASON_PHRASES.put(412, "Precondition Failed"); |
| 75 | + REASON_PHRASES.put(413, "Request Too Long"); |
| 76 | + REASON_PHRASES.put(414, "Request-URI Too Long"); |
| 77 | + REASON_PHRASES.put(415, "Unsupported Media Type"); |
| 78 | + REASON_PHRASES.put(416, "Requested Range Not Satisfiable"); |
| 79 | + REASON_PHRASES.put(417, "Expectation Failed"); |
| 80 | + REASON_PHRASES.put(419, "Insufficient Space On Resource"); |
| 81 | + REASON_PHRASES.put(420, "Method Failure"); |
| 82 | + REASON_PHRASES.put(422, "Unprocessable Entity"); |
| 83 | + REASON_PHRASES.put(423, "Locked"); |
| 84 | + REASON_PHRASES.put(424, "Failed Dependency"); |
| 85 | + REASON_PHRASES.put(500, "Internal Server Error"); |
| 86 | + REASON_PHRASES.put(501, "Not Implemented"); |
| 87 | + REASON_PHRASES.put(502, "Bad Gateway"); |
| 88 | + REASON_PHRASES.put(503, "Service Unavailable"); |
| 89 | + REASON_PHRASES.put(504, "Gateway Timeout"); |
| 90 | + REASON_PHRASES.put(505, "Http Version Not Supported"); |
| 91 | + REASON_PHRASES.put(507, "Insufficient Storage"); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Get the reason phrase for a particular status code. |
| 96 | + * |
| 97 | + * <p>This method always returns the English text as specified in the relevant RFCs and is not |
| 98 | + * internationalized. |
| 99 | + * |
| 100 | + * @param statusCode the numeric status code |
| 101 | + * @return the reason phrase associated with the given status code or null if the status code is |
| 102 | + * not recognized. |
| 103 | + */ |
| 104 | + public static String getReasonPhrase(int statusCode) { |
| 105 | + if (statusCode < 0) { |
| 106 | + throw new IllegalArgumentException("status code may not be negative"); |
| 107 | + } |
| 108 | + return REASON_PHRASES.get(statusCode); |
| 109 | + } |
| 110 | + |
| 111 | + private HttpStatus() {} |
| 112 | +} |
0 commit comments