View Javadoc

1   /*
2    * Copyright (c) 2012 the original author or authors.
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    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.eclipse.jetty.spdy;
18  
19  import org.eclipse.jetty.spdy.api.SPDY;
20  
21  public class CompressionDictionary
22  {
23      private static final byte[] DICTIONARY_V2 = ("" +
24              "optionsgetheadpostputdeletetraceacceptaccept-charsetaccept-encodingaccept-" +
25              "languageauthorizationexpectfromhostif-modified-sinceif-matchif-none-matchi" +
26              "f-rangeif-unmodifiedsincemax-forwardsproxy-authorizationrangerefererteuser" +
27              "-agent10010120020120220320420520630030130230330430530630740040140240340440" +
28              "5406407408409410411412413414415416417500501502503504505accept-rangesageeta" +
29              "glocationproxy-authenticatepublicretry-afterservervarywarningwww-authentic" +
30              "ateallowcontent-basecontent-encodingcache-controlconnectiondatetrailertran" +
31              "sfer-encodingupgradeviawarningcontent-languagecontent-lengthcontent-locati" +
32              "oncontent-md5content-rangecontent-typeetagexpireslast-modifiedset-cookieMo" +
33              "ndayTuesdayWednesdayThursdayFridaySaturdaySundayJanFebMarAprMayJunJulAugSe" +
34              "pOctNovDecchunkedtext/htmlimage/pngimage/jpgimage/gifapplication/xmlapplic" +
35              "ation/xhtmltext/plainpublicmax-agecharset=iso-8859-1utf-8gzipdeflateHTTP/1" +
36              ".1statusversionurl" +
37              // Must be NUL terminated
38              "\u0000").getBytes();
39  
40      private static final byte[] DICTIONARY_V3 = ("" +
41              "\u0000\u0000\u0000\u0007options\u0000\u0000\u0000\u0004head\u0000\u0000\u0000\u0004post" +
42              "\u0000\u0000\u0000\u0003put\u0000\u0000\u0000\u0006delete\u0000\u0000\u0000\u0005trace" +
43              "\u0000\u0000\u0000\u0006accept\u0000\u0000\u0000\u000Eaccept-charset" +
44              "\u0000\u0000\u0000\u000Faccept-encoding\u0000\u0000\u0000\u000Faccept-language" +
45              "\u0000\u0000\u0000\raccept-ranges\u0000\u0000\u0000\u0003age\u0000\u0000\u0000\u0005allow" +
46              "\u0000\u0000\u0000\rauthorization\u0000\u0000\u0000\rcache-control" +
47              "\u0000\u0000\u0000\nconnection\u0000\u0000\u0000\fcontent-base\u0000\u0000\u0000\u0010content-encoding" +
48              "\u0000\u0000\u0000\u0010content-language\u0000\u0000\u0000\u000Econtent-length" +
49              "\u0000\u0000\u0000\u0010content-location\u0000\u0000\u0000\u000Bcontent-md5" +
50              "\u0000\u0000\u0000\rcontent-range\u0000\u0000\u0000\fcontent-type\u0000\u0000\u0000\u0004date" +
51              "\u0000\u0000\u0000\u0004etag\u0000\u0000\u0000\u0006expect\u0000\u0000\u0000\u0007expires" +
52              "\u0000\u0000\u0000\u0004from\u0000\u0000\u0000\u0004host\u0000\u0000\u0000\bif-match" +
53              "\u0000\u0000\u0000\u0011if-modified-since\u0000\u0000\u0000\rif-none-match\u0000\u0000\u0000\bif-range" +
54              "\u0000\u0000\u0000\u0013if-unmodified-since\u0000\u0000\u0000\rlast-modified" +
55              "\u0000\u0000\u0000\blocation\u0000\u0000\u0000\fmax-forwards\u0000\u0000\u0000\u0006pragma" +
56              "\u0000\u0000\u0000\u0012proxy-authenticate\u0000\u0000\u0000\u0013proxy-authorization" +
57              "\u0000\u0000\u0000\u0005range\u0000\u0000\u0000\u0007referer\u0000\u0000\u0000\u000Bretry-after" +
58              "\u0000\u0000\u0000\u0006server\u0000\u0000\u0000\u0002te\u0000\u0000\u0000\u0007trailer" +
59              "\u0000\u0000\u0000\u0011transfer-encoding\u0000\u0000\u0000\u0007upgrade\u0000\u0000\u0000\nuser-agent" +
60              "\u0000\u0000\u0000\u0004vary\u0000\u0000\u0000\u0003via\u0000\u0000\u0000\u0007warning" +
61              "\u0000\u0000\u0000\u0010www-authenticate\u0000\u0000\u0000\u0006method\u0000\u0000\u0000\u0003get" +
62              "\u0000\u0000\u0000\u0006status\u0000\u0000\u0000\u0006200 OK\u0000\u0000\u0000\u0007version" +
63              "\u0000\u0000\u0000\bHTTP/1.1\u0000\u0000\u0000\u0003url\u0000\u0000\u0000\u0006public" +
64              "\u0000\u0000\u0000\nset-cookie\u0000\u0000\u0000\nkeep-alive\u0000\u0000\u0000\u0006origin" +
65              "100101201202205206300302303304305306307402405406407408409410411412413414415416417502504505" +
66              "203 Non-Authoritative Information204 No Content301 Moved Permanently400 Bad Request401 Unauthorized" +
67              "403 Forbidden404 Not Found500 Internal Server Error501 Not Implemented503 Service Unavailable" +
68              "Jan Feb Mar Apr May Jun Jul Aug Sept Oct Nov Dec 00:00:00 Mon, Tue, Wed, Thu, Fri, Sat, Sun, GMT" +
69              "chunked,text/html,image/png,image/jpg,image/gif,application/xml,application/xhtml+xml,text/plain," +
70              "text/javascript,publicprivatemax-age=gzip,deflate,sdchcharset=utf-8charset=iso-8859-1,utf-,*,enq=0.")
71              .getBytes();
72  
73      public static byte[] get(short version)
74      {
75          switch (version)
76          {
77              case SPDY.V2:
78                  return DICTIONARY_V2;
79              case SPDY.V3:
80                  return DICTIONARY_V3;
81              default:
82                  throw new IllegalStateException();
83          }
84      }
85  }