KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > http > HttpConstants


1 /*
2  * $Id: HttpConstants.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

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 JavaDoc;
18 import java.util.Map JavaDoc;
19
20 /**
21  * <code>HttpConstants</code> for request and response headers
22  */

23 // @ThreadSafe
24
public class HttpConstants
25 {
26     // HTTP prefix
27
public static final String JavaDoc HTTP10 = "HTTP/1.0";
28     public static final String JavaDoc HTTP1X = "HTTP/1.x";
29     public static final String JavaDoc HTTP11 = "HTTP/1.1";
30     public static final String JavaDoc DEFAULT_HTTP_VERSION = HttpConstants.HTTP11;
31
32     // Default HTTP port
33
public static final int DEFAULT_HTTP_PORT = 80;
34
35     // HTTP Methods
36
public static final String JavaDoc METHOD_POST = "POST";
37     public static final String JavaDoc METHOD_PUT = "PUT";
38     public static final String JavaDoc METHOD_GET = "GET";
39
40     // Date header format
41
public static final String JavaDoc DATE_FORMAT = "EEE, dd MMM yyyy hh:mm:ss zzz";
42
43     // Newline
44
public static final String JavaDoc CRLF = "\r\n";
45     // Mime/Content separator
46
public static final String JavaDoc HEADER_CONTENT_SEPARATOR = CRLF + CRLF;
47
48     // The default content type
49
public static final String JavaDoc DEFAULT_CONTENT_TYPE = "text/plain";
50
51     // Headers
52
public static final String JavaDoc HEADER_ACCEPT = "Accept";// [Request]
53
public static final String JavaDoc HEADER_ACCEPT_CHARSET = "Accept-Charset";// [Request]
54
public static final String JavaDoc HEADER_ACCEPT_ENCODING = "Accept-Encoding";// [Request]
55
public static final String JavaDoc HEADER_ACCEPT_LANGUAGE = "Accept-Language";// [Request]
56
public static final String JavaDoc HEADER_ACCEPT_RANGES = "Accept-Ranges";// [Response]
57
public static final String JavaDoc HEADER_AGE = "Age";// [Response]
58
public static final String JavaDoc HEADER_ALLOW = "Allow";// [Entity]
59
public static final String JavaDoc HEADER_AUTHORIZATION = "Authorization";// [Request]
60
public static final String JavaDoc HEADER_CACHE_CONTROL = "Cache-Control";// [General]
61
public static final String JavaDoc HEADER_CONNECTION = "Connection";// [General]
62
public static final String JavaDoc HEADER_CONTENT_ENCODING = "Content-Encoding";// [Entity]
63
public static final String JavaDoc HEADER_CONTENT_LANGUAGE = "Content-Language";// [Entity]
64
public static final String JavaDoc HEADER_CONTENT_LENGTH = "Content-Length";// [Entity]
65
public static final String JavaDoc HEADER_CONTENT_LOCATION = "Content-Location";// [Entity]
66
public static final String JavaDoc HEADER_CONTENT_MD5 = "Content-MD5";// [Entity]
67
public static final String JavaDoc HEADER_CONTENT_RANGE = "Content-Range";// [Entity]
68
public static final String JavaDoc HEADER_CONTENT_TYPE = "Content-Type";// [Entity]
69
public static final String JavaDoc HEADER_COOKIE = "Cookie";// [Request]
70
public static final String JavaDoc HEADER_COOKIE_SET = "Set-Cookie";// [Response]
71
public static final String JavaDoc HEADER_DATE = "Date";// [General]
72
public static final String JavaDoc HEADER_ETAG = "ETag";// [Response]
73
public static final String JavaDoc HEADER_EXPECT = "Expect";// [Request]
74
public static final String JavaDoc HEADER_EXPIRES = "Expires";// [Entity]
75
public static final String JavaDoc HEADER_FROM = "From";// [Request]
76
public static final String JavaDoc HEADER_HOST = "Host";// [Request]
77
public static final String JavaDoc HEADER_IF_MATCH = "If-Match";// [Request]
78
public static final String JavaDoc HEADER_IF_MODIFIED_SINCE = "If-Modified-Since";// [Request]
79
public static final String JavaDoc HEADER_IF_NONE_MATCH = "If-None-Match";// [Request]
80
public static final String JavaDoc HEADER_IF_RANGE = "If-Range";// [Request]
81
public static final String JavaDoc HEADER_IF_UNMODIFIED_SINCE = "If-Unmodified-Since";// [Request]
82
public static final String JavaDoc HEADER_KEEP_ALIVE = "Keep-Alive";// [Entity]
83
public static final String JavaDoc HEADER_LAST_MODIFIED = "Last-Modified";// [Entity]
84
public static final String JavaDoc HEADER_LOCATION = "Location";// [Response]
85
public static final String JavaDoc HEADER_MAX_FORWARDS = "Max-Forwards";// [Request]
86
public static final String JavaDoc HEADER_PRAGMA = "Pragma";// [General]
87
public static final String JavaDoc HEADER_PROXY_AUTHENTICATE = "Proxy-Authenticate";// [Response]
88
public static final String JavaDoc HEADER_PROXY_AUTHORIZATION = "Proxy-Authorization";// [Request]
89
public static final String JavaDoc HEADER_RANGE = "Range";// [Request]
90
public static final String JavaDoc HEADER_REFERER = "Referer";// [Request]
91
public static final String JavaDoc HEADER_RETRY_AFTER = "Retry-After";// [Response]
92
public static final String JavaDoc HEADER_SERVER = "Server";// [Response]
93
public static final String JavaDoc HEADER_TE = "TE";// [Request]
94
public static final String JavaDoc HEADER_TRAILER = "Trailer";// [General]
95
public static final String JavaDoc HEADER_TRANSFER_ENCODING = "Transfer-Encoding";// [General]
96
public static final String JavaDoc HEADER_UPGRADE = "Upgrade";// [General]
97
public static final String JavaDoc HEADER_USER_AGENT = "User-Agent";// [Request]
98
public static final String JavaDoc HEADER_VARY = "Vary";// [Response]
99
public static final String JavaDoc HEADER_VIA = "Via";// [General]
100
public static final String JavaDoc HEADER_WARNING = "Warning";// [General]
101
public static final String JavaDoc HEADER_WWW_AUTHENTICATE = "WWW-Authenticate";// [Response]
102

103     // This is a POST-related request header value
104
public static final String JavaDoc HEADER_EXPECT_CONTINUE_REQUEST_VALUE = "100-continue";// [Request]
105

106     // Chunked transfer encoding indicator
107
public static final String JavaDoc TRANSFER_ENCODING_CHUNKED = "chunked";
108
109     // Key for X-MULE headers
110
public static final String JavaDoc X_PROPERTY_PREFIX = "X-" + MuleProperties.PROPERTY_PREFIX;
111
112     // case-insenitive Maps of header names to their normalized representations
113
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     // Status codes
118
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 JavaDoc[] strings = new String JavaDoc[]{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 JavaDoc[]{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 JavaDoc[]{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