001: // ========================================================================
002: // Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
003: // ------------------------------------------------------------------------
004: // Licensed under the Apache License, Version 2.0 (the "License");
005: // you may not use this file except in compliance with the License.
006: // You may obtain a copy of the License at
007: // http://www.apache.org/licenses/LICENSE-2.0
008: // Unless required by applicable law or agreed to in writing, software
009: // distributed under the License is distributed on an "AS IS" BASIS,
010: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011: // See the License for the specific language governing permissions and
012: // limitations under the License.
013: // ========================================================================
014:
015: package org.mortbay.jetty;
016:
017: import org.mortbay.io.Buffer;
018: import org.mortbay.io.BufferCache;
019:
020: /* ------------------------------------------------------------------------------- */
021: /**
022: *
023: * @author gregw
024: */
025: public class HttpHeaders extends BufferCache {
026: /* ------------------------------------------------------------ */
027: /** General Fields.
028: */
029: public final static String CONNECTION = "Connection",
030: CACHE_CONTROL = "Cache-Control", DATE = "Date",
031: PRAGMA = "Pragma", PROXY_CONNECTION = "Proxy-Connection",
032: TRAILER = "Trailer",
033: TRANSFER_ENCODING = "Transfer-Encoding",
034: UPGRADE = "Upgrade", VIA = "Via", WARNING = "Warning";
035:
036: /* ------------------------------------------------------------ */
037: /** Entity Fields.
038: */
039: public final static String ALLOW = "Allow",
040: CONTENT_ENCODING = "Content-Encoding",
041: CONTENT_LANGUAGE = "Content-Language",
042: CONTENT_LENGTH = "Content-Length",
043: CONTENT_LOCATION = "Content-Location",
044: CONTENT_MD5 = "Content-MD5",
045: CONTENT_RANGE = "Content-Range",
046: CONTENT_TYPE = "Content-Type", EXPIRES = "Expires",
047: LAST_MODIFIED = "Last-Modified";
048:
049: /* ------------------------------------------------------------ */
050: /** Request Fields.
051: */
052: public final static String ACCEPT = "Accept",
053: ACCEPT_CHARSET = "Accept-Charset",
054: ACCEPT_ENCODING = "Accept-Encoding",
055: ACCEPT_LANGUAGE = "Accept-Language",
056: AUTHORIZATION = "Authorization", EXPECT = "Expect",
057: FORWARDED = "Forwarded", FROM = "From", HOST = "Host",
058: IF_MATCH = "If-Match",
059: IF_MODIFIED_SINCE = "If-Modified-Since",
060: IF_NONE_MATCH = "If-None-Match", IF_RANGE = "If-Range",
061: IF_UNMODIFIED_SINCE = "If-Unmodified-Since",
062: KEEP_ALIVE = "Keep-Alive", MAX_FORWARDS = "Max-Forwards",
063: PROXY_AUTHORIZATION = "Proxy-Authorization",
064: RANGE = "Range", REQUEST_RANGE = "Request-Range",
065: REFERER = "Referer", TE = "TE", USER_AGENT = "User-Agent",
066: X_FORWARDED_FOR = "X-Forwarded-For";
067:
068: /* ------------------------------------------------------------ */
069: /** Response Fields.
070: */
071: public final static String ACCEPT_RANGES = "Accept-Ranges",
072: AGE = "Age", ETAG = "ETag", LOCATION = "Location",
073: PROXY_AUTHENTICATE = "Proxy-Authenticate",
074: RETRY_AFTER = "Retry-After", SERVER = "Server",
075: SERVLET_ENGINE = "Servlet-Engine", VARY = "Vary",
076: WWW_AUTHENTICATE = "WWW-Authenticate";
077:
078: /* ------------------------------------------------------------ */
079: /** Other Fields.
080: */
081: public final static String COOKIE = "Cookie",
082: SET_COOKIE = "Set-Cookie", SET_COOKIE2 = "Set-Cookie2",
083: MIME_VERSION = "MIME-Version", IDENTITY = "identity";
084:
085: public final static int CONNECTION_ORDINAL = 1, DATE_ORDINAL = 2,
086: PRAGMA_ORDINAL = 3, TRAILER_ORDINAL = 4,
087: TRANSFER_ENCODING_ORDINAL = 5, UPGRADE_ORDINAL = 6,
088: VIA_ORDINAL = 7, WARNING_ORDINAL = 8, ALLOW_ORDINAL = 9,
089: CONTENT_ENCODING_ORDINAL = 10,
090: CONTENT_LANGUAGE_ORDINAL = 11, CONTENT_LENGTH_ORDINAL = 12,
091: CONTENT_LOCATION_ORDINAL = 13, CONTENT_MD5_ORDINAL = 14,
092: CONTENT_RANGE_ORDINAL = 15, CONTENT_TYPE_ORDINAL = 16,
093: EXPIRES_ORDINAL = 17, LAST_MODIFIED_ORDINAL = 18,
094: ACCEPT_ORDINAL = 19, ACCEPT_CHARSET_ORDINAL = 20,
095: ACCEPT_ENCODING_ORDINAL = 21, ACCEPT_LANGUAGE_ORDINAL = 22,
096: AUTHORIZATION_ORDINAL = 23, EXPECT_ORDINAL = 24,
097: FORWARDED_ORDINAL = 25, FROM_ORDINAL = 26,
098: HOST_ORDINAL = 27, IF_MATCH_ORDINAL = 28,
099: IF_MODIFIED_SINCE_ORDINAL = 29, IF_NONE_MATCH_ORDINAL = 30,
100: IF_RANGE_ORDINAL = 31, IF_UNMODIFIED_SINCE_ORDINAL = 32,
101: KEEP_ALIVE_ORDINAL = 33, MAX_FORWARDS_ORDINAL = 34,
102: PROXY_AUTHORIZATION_ORDINAL = 35, RANGE_ORDINAL = 36,
103: REQUEST_RANGE_ORDINAL = 37, REFERER_ORDINAL = 38,
104: TE_ORDINAL = 39, USER_AGENT_ORDINAL = 40,
105: X_FORWARDED_FOR_ORDINAL = 41, ACCEPT_RANGES_ORDINAL = 42,
106: AGE_ORDINAL = 43, ETAG_ORDINAL = 44, LOCATION_ORDINAL = 45,
107: PROXY_AUTHENTICATE_ORDINAL = 46, RETRY_AFTER_ORDINAL = 47,
108: SERVER_ORDINAL = 48, SERVLET_ENGINE_ORDINAL = 49,
109: VARY_ORDINAL = 50, WWW_AUTHENTICATE_ORDINAL = 51,
110: COOKIE_ORDINAL = 52, SET_COOKIE_ORDINAL = 53,
111: SET_COOKIE2_ORDINAL = 54, MIME_VERSION_ORDINAL = 55,
112: IDENTITY_ORDINAL = 56, CACHE_CONTROL_ORDINAL = 57,
113: PROXY_CONNECTION_ORDINAL = 58;
114:
115: public final static HttpHeaders CACHE = new HttpHeaders();
116:
117: public final static Buffer HOST_BUFFER = CACHE.add(HOST,
118: HOST_ORDINAL), ACCEPT_BUFFER = CACHE.add(ACCEPT,
119: ACCEPT_ORDINAL), ACCEPT_CHARSET_BUFFER = CACHE.add(
120: ACCEPT_CHARSET, ACCEPT_CHARSET_ORDINAL),
121: ACCEPT_ENCODING_BUFFER = CACHE.add(ACCEPT_ENCODING,
122: ACCEPT_ENCODING_ORDINAL),
123: ACCEPT_LANGUAGE_BUFFER = CACHE.add(ACCEPT_LANGUAGE,
124: ACCEPT_LANGUAGE_ORDINAL),
125:
126: CONTENT_LENGTH_BUFFER = CACHE.add(CONTENT_LENGTH,
127: CONTENT_LENGTH_ORDINAL), CONNECTION_BUFFER = CACHE
128: .add(CONNECTION, CONNECTION_ORDINAL),
129: CACHE_CONTROL_BUFFER = CACHE.add(CACHE_CONTROL,
130: CACHE_CONTROL_ORDINAL), DATE_BUFFER = CACHE.add(
131: DATE, DATE_ORDINAL), PRAGMA_BUFFER = CACHE.add(
132: PRAGMA, PRAGMA_ORDINAL), TRAILER_BUFFER = CACHE
133: .add(TRAILER, TRAILER_ORDINAL),
134: TRANSFER_ENCODING_BUFFER = CACHE.add(TRANSFER_ENCODING,
135: TRANSFER_ENCODING_ORDINAL), UPGRADE_BUFFER = CACHE
136: .add(UPGRADE, UPGRADE_ORDINAL), VIA_BUFFER = CACHE
137: .add(VIA, VIA_ORDINAL), WARNING_BUFFER = CACHE.add(
138: WARNING, WARNING_ORDINAL), ALLOW_BUFFER = CACHE
139: .add(ALLOW, ALLOW_ORDINAL),
140: CONTENT_ENCODING_BUFFER = CACHE.add(CONTENT_ENCODING,
141: CONTENT_ENCODING_ORDINAL),
142: CONTENT_LANGUAGE_BUFFER = CACHE.add(CONTENT_LANGUAGE,
143: CONTENT_LANGUAGE_ORDINAL),
144: CONTENT_LOCATION_BUFFER = CACHE.add(CONTENT_LOCATION,
145: CONTENT_LOCATION_ORDINAL),
146: CONTENT_MD5_BUFFER = CACHE.add(CONTENT_MD5,
147: CONTENT_MD5_ORDINAL), CONTENT_RANGE_BUFFER = CACHE
148: .add(CONTENT_RANGE, CONTENT_RANGE_ORDINAL),
149: CONTENT_TYPE_BUFFER = CACHE.add(CONTENT_TYPE,
150: CONTENT_TYPE_ORDINAL), EXPIRES_BUFFER = CACHE.add(
151: EXPIRES, EXPIRES_ORDINAL),
152: LAST_MODIFIED_BUFFER = CACHE.add(LAST_MODIFIED,
153: LAST_MODIFIED_ORDINAL),
154: AUTHORIZATION_BUFFER = CACHE.add(AUTHORIZATION,
155: AUTHORIZATION_ORDINAL), EXPECT_BUFFER = CACHE.add(
156: EXPECT, EXPECT_ORDINAL), FORWARDED_BUFFER = CACHE
157: .add(FORWARDED, FORWARDED_ORDINAL),
158: FROM_BUFFER = CACHE.add(FROM, FROM_ORDINAL),
159: IF_MATCH_BUFFER = CACHE.add(IF_MATCH, IF_MATCH_ORDINAL),
160: IF_MODIFIED_SINCE_BUFFER = CACHE.add(IF_MODIFIED_SINCE,
161: IF_MODIFIED_SINCE_ORDINAL),
162: IF_NONE_MATCH_BUFFER = CACHE.add(IF_NONE_MATCH,
163: IF_NONE_MATCH_ORDINAL), IF_RANGE_BUFFER = CACHE
164: .add(IF_RANGE, IF_RANGE_ORDINAL),
165: IF_UNMODIFIED_SINCE_BUFFER = CACHE.add(IF_UNMODIFIED_SINCE,
166: IF_UNMODIFIED_SINCE_ORDINAL),
167: KEEP_ALIVE_BUFFER = CACHE.add(KEEP_ALIVE,
168: KEEP_ALIVE_ORDINAL), MAX_FORWARDS_BUFFER = CACHE
169: .add(MAX_FORWARDS, MAX_FORWARDS_ORDINAL),
170: PROXY_AUTHORIZATION_BUFFER = CACHE.add(PROXY_AUTHORIZATION,
171: PROXY_AUTHORIZATION_ORDINAL), RANGE_BUFFER = CACHE
172: .add(RANGE, RANGE_ORDINAL),
173: REQUEST_RANGE_BUFFER = CACHE.add(REQUEST_RANGE,
174: REQUEST_RANGE_ORDINAL), REFERER_BUFFER = CACHE.add(
175: REFERER, REFERER_ORDINAL), TE_BUFFER = CACHE.add(
176: TE, TE_ORDINAL), USER_AGENT_BUFFER = CACHE.add(
177: USER_AGENT, USER_AGENT_ORDINAL),
178: X_FORWARDED_FOR_BUFFER = CACHE.add(X_FORWARDED_FOR,
179: X_FORWARDED_FOR_ORDINAL),
180: ACCEPT_RANGES_BUFFER = CACHE.add(ACCEPT_RANGES,
181: ACCEPT_RANGES_ORDINAL), AGE_BUFFER = CACHE.add(AGE,
182: AGE_ORDINAL), ETAG_BUFFER = CACHE.add(ETAG,
183: ETAG_ORDINAL), LOCATION_BUFFER = CACHE.add(
184: LOCATION, LOCATION_ORDINAL),
185: PROXY_AUTHENTICATE_BUFFER = CACHE.add(PROXY_AUTHENTICATE,
186: PROXY_AUTHENTICATE_ORDINAL),
187: RETRY_AFTER_BUFFER = CACHE.add(RETRY_AFTER,
188: RETRY_AFTER_ORDINAL), SERVER_BUFFER = CACHE.add(
189: SERVER, SERVER_ORDINAL),
190: SERVLET_ENGINE_BUFFER = CACHE.add(SERVLET_ENGINE,
191: SERVLET_ENGINE_ORDINAL), VARY_BUFFER = CACHE.add(
192: VARY, VARY_ORDINAL),
193: WWW_AUTHENTICATE_BUFFER = CACHE.add(WWW_AUTHENTICATE,
194: WWW_AUTHENTICATE_ORDINAL), COOKIE_BUFFER = CACHE
195: .add(COOKIE, COOKIE_ORDINAL),
196: SET_COOKIE_BUFFER = CACHE.add(SET_COOKIE,
197: SET_COOKIE_ORDINAL), SET_COOKIE2_BUFFER = CACHE
198: .add(SET_COOKIE2, SET_COOKIE2_ORDINAL),
199: MIME_VERSION_BUFFER = CACHE.add(MIME_VERSION,
200: MIME_VERSION_ORDINAL), IDENTITY_BUFFER = CACHE.add(
201: IDENTITY, IDENTITY_ORDINAL),
202: PROXY_CONNECTION_BUFFER = CACHE.add(PROXY_CONNECTION,
203: PROXY_CONNECTION_ORDINAL);
204: }
|