View Javadoc

1   /*
2    * Copyright 2012 The Netty Project
3    *
4    * The Netty Project licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. 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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  package org.jboss.netty.handler.codec.http.websocketx;
17  
18  /**
19   * <p>
20   * Versions of the web socket specification.
21   * </p>
22   * <p>
23   * A specification is tied to one wire protocol version but a protocol version may have use by more than 1 version of
24   * the specification.
25   * </p>
26   */
27  public enum WebSocketVersion {
28      UNKNOWN,
29  
30      /**
31       * <a href= "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00"
32       * >draft-ietf-hybi-thewebsocketprotocol- 00</a>.
33       */
34      V00,
35  
36      /**
37       * <a href= "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-07"
38       * >draft-ietf-hybi-thewebsocketprotocol- 07</a>
39       */
40      V07,
41  
42      /**
43       * <a href= "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-10"
44       * >draft-ietf-hybi-thewebsocketprotocol- 10</a>
45       */
46      V08,
47  
48      /**
49       * <a href="http://tools.ietf.org/html/rfc6455 ">RFC 6455</a>. This was originally <a href=
50       * "http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17" >draft-ietf-hybi-thewebsocketprotocol-
51       * 17</a>
52       */
53      V13;
54  
55      /**
56       * @return Value for HTTP Header 'Sec-WebSocket-Version'
57       */
58      public String toHttpHeaderValue() {
59          if (this == V00) {
60              return "0";
61          }
62          if (this == V07) {
63              return "7";
64          }
65          if (this == V08) {
66              return "8";
67          }
68          if (this == V13) {
69              return "13";
70          }
71          throw new IllegalStateException("Unknown web socket version: " + this);
72      }
73  }