1 10 11 package org.mule.providers.http; 12 13 import org.apache.commons.collections.map.CaseInsensitiveMap; 14 import org.mule.config.MuleProperties; 15 import org.mule.util.MapUtils; 16 17 import java.util.Collections ; 18 import java.util.Map ; 19 20 23 public class HttpConstants 25 { 26 public static final String HTTP10 = "HTTP/1.0"; 28 public static final String HTTP1X = "HTTP/1.x"; 29 public static final String HTTP11 = "HTTP/1.1"; 30 public static final String DEFAULT_HTTP_VERSION = HttpConstants.HTTP11; 31 32 public static final int DEFAULT_HTTP_PORT = 80; 34 35 public static final String METHOD_POST = "POST"; 37 public static final String METHOD_PUT = "PUT"; 38 public static final String METHOD_GET = "GET"; 39 40 public static final String DATE_FORMAT = "EEE, dd MMM yyyy hh:mm:ss zzz"; 42 43 public static final String CRLF = "\r\n"; 45 public static final String HEADER_CONTENT_SEPARATOR = CRLF + CRLF; 47 48 public static final String DEFAULT_CONTENT_TYPE = "text/plain"; 50 51 public static final String HEADER_ACCEPT = "Accept"; public static final String HEADER_ACCEPT_CHARSET = "Accept-Charset"; public static final String HEADER_ACCEPT_ENCODING = "Accept-Encoding"; public static final String HEADER_ACCEPT_LANGUAGE = "Accept-Language"; public static final String HEADER_ACCEPT_RANGES = "Accept-Ranges"; public static final String HEADER_AGE = "Age"; public static final String HEADER_ALLOW = "Allow"; public static final String HEADER_AUTHORIZATION = "Authorization"; public static final String HEADER_CACHE_CONTROL = "Cache-Control"; public static final String HEADER_CONNECTION = "Connection"; public static final String HEADER_CONTENT_ENCODING = "Content-Encoding"; public static final String HEADER_CONTENT_LANGUAGE = "Content-Language"; public static final String HEADER_CONTENT_LENGTH = "Content-Length"; public static final String HEADER_CONTENT_LOCATION = "Content-Location"; public static final String HEADER_CONTENT_MD5 = "Content-MD5"; public static final String HEADER_CONTENT_RANGE = "Content-Range"; public static final String HEADER_CONTENT_TYPE = "Content-Type"; public static final String HEADER_COOKIE = "Cookie"; public static final String HEADER_COOKIE_SET = "Set-Cookie"; public static final String HEADER_DATE = "Date"; public static final String HEADER_ETAG = "ETag"; public static final String HEADER_EXPECT = "Expect"; public static final String HEADER_EXPIRES = "Expires"; public static final String HEADER_FROM = "From"; public static final String HEADER_HOST = "Host"; public static final String HEADER_IF_MATCH = "If-Match"; public static final String HEADER_IF_MODIFIED_SINCE = "If-Modified-Since"; public static final String HEADER_IF_NONE_MATCH = "If-None-Match"; public static final String HEADER_IF_RANGE = "If-Range"; public static final String HEADER_IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; public static final String HEADER_KEEP_ALIVE = "Keep-Alive"; public static final String HEADER_LAST_MODIFIED = "Last-Modified"; public static final String HEADER_LOCATION = "Location"; public static final String HEADER_MAX_FORWARDS = "Max-Forwards"; public static final String HEADER_PRAGMA = "Pragma"; public static final String HEADER_PROXY_AUTHENTICATE = "Proxy-Authenticate"; public static final String HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization"; public static final String HEADER_RANGE = "Range"; public static final String HEADER_REFERER = "Referer"; public static final String HEADER_RETRY_AFTER = "Retry-After"; public static final String HEADER_SERVER = "Server"; public static final String HEADER_TE = "TE"; public static final String HEADER_TRAILER = "Trailer"; public static final String HEADER_TRANSFER_ENCODING = "Transfer-Encoding"; public static final String HEADER_UPGRADE = "Upgrade"; public static final String HEADER_USER_AGENT = "User-Agent"; public static final String HEADER_VARY = "Vary"; public static final String HEADER_VIA = "Via"; public static final String HEADER_WARNING = "Warning"; public static final String HEADER_WWW_AUTHENTICATE = "WWW-Authenticate"; 103 public static final String HEADER_EXPECT_CONTINUE_REQUEST_VALUE = "100-continue"; 106 public static final String TRANSFER_ENCODING_CHUNKED = "chunked"; 108 109 public static final String X_PROPERTY_PREFIX = "X-" + MuleProperties.PROPERTY_PREFIX; 111 112 public static final Map REQUEST_HEADER_NAMES; 114 public static final Map RESPONSE_HEADER_NAMES; 115 public static final Map ALL_HEADER_NAMES; 116 117 public static final int SC_CONTINUE = 100; 119 public static final int SC_SWITCHING_PROTOCOLS = 101; 120 public static final int SC_PROCESSING = 102; 121 public static final int SC_OK = 200; 122 public static final int SC_CREATED = 201; 123 public static final int SC_ACCEPTED = 202; 124 public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203; 125 public static final int SC_NO_CONTENT = 204; 126 public static final int SC_RESET_CONTENT = 205; 127 public static final int SC_PARTIAL_CONTENT = 206; 128 public static final int SC_MULTI_STATUS = 207; 129 public static final int SC_MULTIPLE_CHOICES = 300; 130 public static final int SC_MOVED_PERMANENTLY = 301; 131 public static final int SC_MOVED_TEMPORARILY = 302; 132 public static final int SC_SEE_OTHER = 303; 133 public static final int SC_NOT_MODIFIED = 304; 134 public static final int SC_USE_PROXY = 305; 135 public static final int SC_TEMPORARY_REDIRECT = 307; 136 public static final int SC_BAD_REQUEST = 400; 137 public static final int SC_UNAUTHORIZED = 401; 138 public static final int SC_PAYMENT_REQUIRED = 402; 139 public static final int SC_FORBIDDEN = 403; 140 public static final int SC_NOT_FOUND = 404; 141 public static final int SC_METHOD_NOT_ALLOWED = 405; 142 public static final int SC_NOT_ACCEPTABLE = 406; 143 public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407; 144 public static final int SC_REQUEST_TIMEOUT = 408; 145 public static final int SC_CONFLICT = 409; 146 public static final int SC_GONE = 410; 147 public static final int SC_LENGTH_REQUIRED = 411; 148 public static final int SC_PRECONDITION_FAILED = 412; 149 public static final int SC_REQUEST_TOO_LONG = 413; 150 public static final int SC_REQUEST_URI_TOO_LONG = 414; 151 public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; 152 public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416; 153 public static final int SC_EXPECTATION_FAILED = 417; 154 public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419; 155 public static final int SC_METHOD_FAILURE = 420; 156 public static final int SC_UNPROCESSABLE_ENTITY = 422; 157 public static final int SC_LOCKED = 423; 158 public static final int SC_FAILED_DEPENDENCY = 424; 159 public static final int SC_INTERNAL_SERVER_ERROR = 500; 160 public static final int SC_NOT_IMPLEMENTED = 501; 161 public static final int SC_BAD_GATEWAY = 502; 162 public static final int SC_SERVICE_UNAVAILABLE = 503; 163 public static final int SC_GATEWAY_TIMEOUT = 504; 164 public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505; 165 public static final int SC_INSUFFICIENT_STORAGE = 507; 166 167 static 168 { 169 String [] strings = new String []{HEADER_ACCEPT, HEADER_ACCEPT_CHARSET, HEADER_ACCEPT_ENCODING, 170 HEADER_ACCEPT_LANGUAGE, HEADER_AUTHORIZATION, HEADER_CACHE_CONTROL, HEADER_CONNECTION, 171 HEADER_COOKIE, HEADER_DATE, HEADER_EXPECT, HEADER_FROM, HEADER_HOST, HEADER_IF_MATCH, 172 HEADER_IF_MODIFIED_SINCE, HEADER_IF_NONE_MATCH, HEADER_IF_RANGE, HEADER_IF_UNMODIFIED_SINCE, 173 HEADER_MAX_FORWARDS, HEADER_PRAGMA, HEADER_PROXY_AUTHORIZATION, HEADER_RANGE, HEADER_REFERER, 174 HEADER_TE, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, HEADER_UPGRADE, HEADER_USER_AGENT, 175 HEADER_VIA, HEADER_WARNING}; 176 177 REQUEST_HEADER_NAMES = Collections.unmodifiableMap(MapUtils.mapWithKeysAndValues( 178 CaseInsensitiveMap.class, strings, strings)); 179 180 strings = new String []{HEADER_ACCEPT_RANGES, HEADER_AGE, HEADER_ALLOW, HEADER_CACHE_CONTROL, 181 HEADER_CONNECTION, HEADER_CONTENT_ENCODING, HEADER_CONTENT_LANGUAGE, HEADER_COOKIE_SET, 182 HEADER_CONTENT_LOCATION, HEADER_CONTENT_MD5, HEADER_CONTENT_RANGE, HEADER_DATE, HEADER_ETAG, 183 HEADER_EXPIRES, HEADER_LAST_MODIFIED, HEADER_LOCATION, HEADER_PRAGMA, HEADER_PROXY_AUTHENTICATE, 184 HEADER_RETRY_AFTER, HEADER_SERVER, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, HEADER_UPGRADE, 185 HEADER_VARY, HEADER_VIA, HEADER_WARNING, HEADER_WWW_AUTHENTICATE}; 186 187 RESPONSE_HEADER_NAMES = Collections.unmodifiableMap(MapUtils.mapWithKeysAndValues( 188 CaseInsensitiveMap.class, strings, strings)); 189 190 strings = new String []{HEADER_ALLOW, HEADER_CACHE_CONTROL, HEADER_CONNECTION, 191 HEADER_CONTENT_ENCODING, HEADER_CONTENT_LANGUAGE, HEADER_CONTENT_LENGTH, HEADER_CONTENT_LOCATION, 192 HEADER_CONTENT_MD5, HEADER_CONTENT_RANGE, HEADER_CONTENT_TYPE, HEADER_DATE, HEADER_EXPIRES, 193 HEADER_KEEP_ALIVE, HEADER_LAST_MODIFIED, HEADER_PRAGMA, HEADER_TRAILER, HEADER_TRANSFER_ENCODING, 194 HEADER_UPGRADE, HEADER_VIA, HEADER_WARNING}; 195 196 Map allHeaders = MapUtils.mapWithKeysAndValues(CaseInsensitiveMap.class, strings, strings); 197 allHeaders.putAll(REQUEST_HEADER_NAMES); 198 allHeaders.putAll(RESPONSE_HEADER_NAMES); 199 ALL_HEADER_NAMES = Collections.unmodifiableMap(allHeaders); 200 } 201 202 } 203 | Popular Tags |