View Javadoc

    1   // ========================================================================
    2   // Copyright 2004-2005 Mort Bay Consulting Pty. Ltd.
    3   // ------------------------------------------------------------------------
    4   // Licensed under the Apache License, Version 2.0 (the "License");
    5   // you may not use this file except in compliance with the License.
    6   // You may obtain a copy of the License at
    7   // http://www.apache.org/licenses/LICENSE-2.0
    8   // Unless required by applicable law or agreed to in writing, software
    9   // distributed under the License is distributed on an "AS IS" BASIS,
    10  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  // ========================================================================
    14
    15  package org.mortbay.jetty;
    16
    17  import org.mortbay.io.Buffer;
    18  import org.mortbay.io.BufferCache;
    19
    20  /* ------------------------------------------------------------------------------- */
    21  /**
    22   *
    23   * @author gregw
    24   */
    25  public class HttpHeaders extends BufferCache
    26  {
    27      /* ------------------------------------------------------------ */
    28      /** General Fields.
    29       */
    30      public final static String
    31          CONNECTION= "Connection",
    32          CACHE_CONTROL= "Cache-Control",
    33          DATE= "Date",
    34          PRAGMA= "Pragma",
    35          PROXY_CONNECTION = "Proxy-Connection",
    36          TRAILER= "Trailer",
    37          TRANSFER_ENCODING= "Transfer-Encoding",
    38          UPGRADE= "Upgrade",
    39          VIA= "Via",
    40          WARNING= "Warning";
    41
    42      /* ------------------------------------------------------------ */
    43      /** Entity Fields.
    44       */
    45      public final static String ALLOW= "Allow",
    46          CONTENT_ENCODING= "Content-Encoding",
    47          CONTENT_LANGUAGE= "Content-Language",
    48          CONTENT_LENGTH= "Content-Length",
    49          CONTENT_LOCATION= "Content-Location",
    50          CONTENT_MD5= "Content-MD5",
    51          CONTENT_RANGE= "Content-Range",
    52          CONTENT_TYPE= "Content-Type",
    53          EXPIRES= "Expires",
    54          LAST_MODIFIED= "Last-Modified";
    55
    56      /* ------------------------------------------------------------ */
    57      /** Request Fields.
    58       */
    59      public final static String ACCEPT= "Accept",
    60          ACCEPT_CHARSET= "Accept-Charset",
    61          ACCEPT_ENCODING= "Accept-Encoding",
    62          ACCEPT_LANGUAGE= "Accept-Language",
    63          AUTHORIZATION= "Authorization",
    64          EXPECT= "Expect",
    65          FORWARDED= "Forwarded",
    66          FROM= "From",
    67          HOST= "Host",
    68          IF_MATCH= "If-Match",
    69          IF_MODIFIED_SINCE= "If-Modified-Since",
    70          IF_NONE_MATCH= "If-None-Match",
    71          IF_RANGE= "If-Range",
    72          IF_UNMODIFIED_SINCE= "If-Unmodified-Since",
    73          KEEP_ALIVE= "Keep-Alive",
    74          MAX_FORWARDS= "Max-Forwards",
    75          PROXY_AUTHORIZATION= "Proxy-Authorization",
    76          RANGE= "Range",
    77          REQUEST_RANGE= "Request-Range",
    78          REFERER= "Referer",
    79          TE= "TE",
    80          USER_AGENT= "User-Agent",
    81          X_FORWARDED_FOR= "X-Forwarded-For";
    82
    83      /* ------------------------------------------------------------ */
    84      /** Response Fields.
    85       */
    86      public final static String ACCEPT_RANGES= "Accept-Ranges",
    87          AGE= "Age",
    88          ETAG= "ETag",
    89          LOCATION= "Location",
    90          PROXY_AUTHENTICATE= "Proxy-Authenticate",
    91          RETRY_AFTER= "Retry-After",
    92          SERVER= "Server",
    93          SERVLET_ENGINE= "Servlet-Engine",
    94          VARY= "Vary",
    95          WWW_AUTHENTICATE= "WWW-Authenticate";
    96
    97      /* ------------------------------------------------------------ */
    98      /** Other Fields.
    99       */
    100     public final static String COOKIE= "Cookie",
    101         SET_COOKIE= "Set-Cookie",
    102         SET_COOKIE2= "Set-Cookie2",
    103         MIME_VERSION= "MIME-Version",
    104         IDENTITY= "identity";
    105
    106     public final static int CONNECTION_ORDINAL= 1,
    107         DATE_ORDINAL= 2,
    108         PRAGMA_ORDINAL= 3,
    109         TRAILER_ORDINAL= 4,
    110         TRANSFER_ENCODING_ORDINAL= 5,
    111         UPGRADE_ORDINAL= 6,
    112         VIA_ORDINAL= 7,
    113         WARNING_ORDINAL= 8,
    114         ALLOW_ORDINAL= 9,
    115         CONTENT_ENCODING_ORDINAL= 10,
    116         CONTENT_LANGUAGE_ORDINAL= 11,
    117         CONTENT_LENGTH_ORDINAL= 12,
    118         CONTENT_LOCATION_ORDINAL= 13,
    119         CONTENT_MD5_ORDINAL= 14,
    120         CONTENT_RANGE_ORDINAL= 15,
    121         CONTENT_TYPE_ORDINAL= 16,
    122         EXPIRES_ORDINAL= 17,
    123         LAST_MODIFIED_ORDINAL= 18,
    124         ACCEPT_ORDINAL= 19,
    125         ACCEPT_CHARSET_ORDINAL= 20,
    126         ACCEPT_ENCODING_ORDINAL= 21,
    127         ACCEPT_LANGUAGE_ORDINAL= 22,
    128         AUTHORIZATION_ORDINAL= 23,
    129         EXPECT_ORDINAL= 24,
    130         FORWARDED_ORDINAL= 25,
    131         FROM_ORDINAL= 26,
    132         HOST_ORDINAL= 27,
    133         IF_MATCH_ORDINAL= 28,
    134         IF_MODIFIED_SINCE_ORDINAL= 29,
    135         IF_NONE_MATCH_ORDINAL= 30,
    136         IF_RANGE_ORDINAL= 31,
    137         IF_UNMODIFIED_SINCE_ORDINAL= 32,
    138         KEEP_ALIVE_ORDINAL= 33,
    139         MAX_FORWARDS_ORDINAL= 34,
    140         PROXY_AUTHORIZATION_ORDINAL= 35,
    141         RANGE_ORDINAL= 36,
    142         REQUEST_RANGE_ORDINAL= 37,
    143         REFERER_ORDINAL= 38,
    144         TE_ORDINAL= 39,
    145         USER_AGENT_ORDINAL= 40,
    146         X_FORWARDED_FOR_ORDINAL= 41,
    147         ACCEPT_RANGES_ORDINAL= 42,
    148         AGE_ORDINAL= 43,
    149         ETAG_ORDINAL= 44,
    150         LOCATION_ORDINAL= 45,
    151         PROXY_AUTHENTICATE_ORDINAL= 46,
    152         RETRY_AFTER_ORDINAL= 47,
    153         SERVER_ORDINAL= 48,
    154         SERVLET_ENGINE_ORDINAL= 49,
    155         VARY_ORDINAL= 50,
    156         WWW_AUTHENTICATE_ORDINAL= 51,
    157         COOKIE_ORDINAL= 52,
    158         SET_COOKIE_ORDINAL= 53,
    159         SET_COOKIE2_ORDINAL= 54,
    160         MIME_VERSION_ORDINAL= 55,
    161         IDENTITY_ORDINAL= 56,
    162         CACHE_CONTROL_ORDINAL=57,
    163         PROXY_CONNECTION_ORDINAL=58;
    164
    165     public final static HttpHeaders CACHE= new HttpHeaders();
    166
    167     public final static Buffer
    168         HOST_BUFFER=CACHE.add(HOST,HOST_ORDINAL),
    169         ACCEPT_BUFFER=CACHE.add(ACCEPT,ACCEPT_ORDINAL),
    170         ACCEPT_CHARSET_BUFFER=CACHE.add(ACCEPT_CHARSET,ACCEPT_CHARSET_ORDINAL),
    171         ACCEPT_ENCODING_BUFFER=CACHE.add(ACCEPT_ENCODING,ACCEPT_ENCODING_ORDINAL),
    172         ACCEPT_LANGUAGE_BUFFER=CACHE.add(ACCEPT_LANGUAGE,ACCEPT_LANGUAGE_ORDINAL),
    173
    174         CONTENT_LENGTH_BUFFER=CACHE.add(CONTENT_LENGTH,CONTENT_LENGTH_ORDINAL),
    175         CONNECTION_BUFFER=CACHE.add(CONNECTION,CONNECTION_ORDINAL),
    176         CACHE_CONTROL_BUFFER=CACHE.add(CACHE_CONTROL,CACHE_CONTROL_ORDINAL),
    177         DATE_BUFFER=CACHE.add(DATE,DATE_ORDINAL),
    178         PRAGMA_BUFFER=CACHE.add(PRAGMA,PRAGMA_ORDINAL),
    179         TRAILER_BUFFER=CACHE.add(TRAILER,TRAILER_ORDINAL),
    180         TRANSFER_ENCODING_BUFFER=CACHE.add(TRANSFER_ENCODING,TRANSFER_ENCODING_ORDINAL),
    181         UPGRADE_BUFFER=CACHE.add(UPGRADE,UPGRADE_ORDINAL),
    182         VIA_BUFFER=CACHE.add(VIA,VIA_ORDINAL),
    183         WARNING_BUFFER=CACHE.add(WARNING,WARNING_ORDINAL),
    184         ALLOW_BUFFER=CACHE.add(ALLOW,ALLOW_ORDINAL),
    185         CONTENT_ENCODING_BUFFER=CACHE.add(CONTENT_ENCODING,CONTENT_ENCODING_ORDINAL),
    186         CONTENT_LANGUAGE_BUFFER=CACHE.add(CONTENT_LANGUAGE,CONTENT_LANGUAGE_ORDINAL),
    187         CONTENT_LOCATION_BUFFER=CACHE.add(CONTENT_LOCATION,CONTENT_LOCATION_ORDINAL),
    188         CONTENT_MD5_BUFFER=CACHE.add(CONTENT_MD5,CONTENT_MD5_ORDINAL),
    189         CONTENT_RANGE_BUFFER=CACHE.add(CONTENT_RANGE,CONTENT_RANGE_ORDINAL),
    190         CONTENT_TYPE_BUFFER=CACHE.add(CONTENT_TYPE,CONTENT_TYPE_ORDINAL),
    191         EXPIRES_BUFFER=CACHE.add(EXPIRES,EXPIRES_ORDINAL),
    192         LAST_MODIFIED_BUFFER=CACHE.add(LAST_MODIFIED,LAST_MODIFIED_ORDINAL),
    193         AUTHORIZATION_BUFFER=CACHE.add(AUTHORIZATION,AUTHORIZATION_ORDINAL),
    194         EXPECT_BUFFER=CACHE.add(EXPECT,EXPECT_ORDINAL),
    195         FORWARDED_BUFFER=CACHE.add(FORWARDED,FORWARDED_ORDINAL),
    196         FROM_BUFFER=CACHE.add(FROM,FROM_ORDINAL),
    197         IF_MATCH_BUFFER=CACHE.add(IF_MATCH,IF_MATCH_ORDINAL),
    198         IF_MODIFIED_SINCE_BUFFER=CACHE.add(IF_MODIFIED_SINCE,IF_MODIFIED_SINCE_ORDINAL),
    199         IF_NONE_MATCH_BUFFER=CACHE.add(IF_NONE_MATCH,IF_NONE_MATCH_ORDINAL),
    200         IF_RANGE_BUFFER=CACHE.add(IF_RANGE,IF_RANGE_ORDINAL),
    201         IF_UNMODIFIED_SINCE_BUFFER=CACHE.add(IF_UNMODIFIED_SINCE,IF_UNMODIFIED_SINCE_ORDINAL),
    202         KEEP_ALIVE_BUFFER=CACHE.add(KEEP_ALIVE,KEEP_ALIVE_ORDINAL),
    203         MAX_FORWARDS_BUFFER=CACHE.add(MAX_FORWARDS,MAX_FORWARDS_ORDINAL),
    204         PROXY_AUTHORIZATION_BUFFER=CACHE.add(PROXY_AUTHORIZATION,PROXY_AUTHORIZATION_ORDINAL),
    205         RANGE_BUFFER=CACHE.add(RANGE,RANGE_ORDINAL),
    206         REQUEST_RANGE_BUFFER=CACHE.add(REQUEST_RANGE,REQUEST_RANGE_ORDINAL),
    207         REFERER_BUFFER=CACHE.add(REFERER,REFERER_ORDINAL),
    208         TE_BUFFER=CACHE.add(TE,TE_ORDINAL),
    209         USER_AGENT_BUFFER=CACHE.add(USER_AGENT,USER_AGENT_ORDINAL),
    210         X_FORWARDED_FOR_BUFFER=CACHE.add(X_FORWARDED_FOR,X_FORWARDED_FOR_ORDINAL),
    211         ACCEPT_RANGES_BUFFER=CACHE.add(ACCEPT_RANGES,ACCEPT_RANGES_ORDINAL),
    212         AGE_BUFFER=CACHE.add(AGE,AGE_ORDINAL),
    213         ETAG_BUFFER=CACHE.add(ETAG,ETAG_ORDINAL),
    214         LOCATION_BUFFER=CACHE.add(LOCATION,LOCATION_ORDINAL),
    215         PROXY_AUTHENTICATE_BUFFER=CACHE.add(PROXY_AUTHENTICATE,PROXY_AUTHENTICATE_ORDINAL),
    216         RETRY_AFTER_BUFFER=CACHE.add(RETRY_AFTER,RETRY_AFTER_ORDINAL),
    217         SERVER_BUFFER=CACHE.add(SERVER,SERVER_ORDINAL),
    218         SERVLET_ENGINE_BUFFER=CACHE.add(SERVLET_ENGINE,SERVLET_ENGINE_ORDINAL),
    219         VARY_BUFFER=CACHE.add(VARY,VARY_ORDINAL),
    220         WWW_AUTHENTICATE_BUFFER=CACHE.add(WWW_AUTHENTICATE,WWW_AUTHENTICATE_ORDINAL),
    221         COOKIE_BUFFER=CACHE.add(COOKIE,COOKIE_ORDINAL),
    222         SET_COOKIE_BUFFER=CACHE.add(SET_COOKIE,SET_COOKIE_ORDINAL),
    223         SET_COOKIE2_BUFFER=CACHE.add(SET_COOKIE2,SET_COOKIE2_ORDINAL),
    224         MIME_VERSION_BUFFER=CACHE.add(MIME_VERSION,MIME_VERSION_ORDINAL),
    225         IDENTITY_BUFFER=CACHE.add(IDENTITY,IDENTITY_ORDINAL),
    226         PROXY_CONNECTION_BUFFER=CACHE.add(PROXY_CONNECTION,PROXY_CONNECTION_ORDINAL);
    227 }