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 * https://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 io.netty5.handler.codec.http.websocketx;
17
18 import io.netty5.util.AsciiString;
19
20 /**
21 * <p>
22 * Versions of the web socket specification.
23 * </p>
24 * <p>
25 * A specification is tied to one wire protocol version but a protocol version may have use by more than 1 version of
26 * the specification.
27 * </p>
28 */
29 public enum WebSocketVersion {
30
31 UNKNOWN(AsciiString.cached("unknown")),
32
33 /**
34 * <a href="https://tools.ietf.org/html/rfc6455 ">RFC 6455</a>. This was originally <a href=
35 * "https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17" >draft-ietf-hybi-thewebsocketprotocol-
36 * 17</a>
37 */
38 V13(AsciiString.cached("13"));
39
40 private final AsciiString headerValue;
41
42 WebSocketVersion(AsciiString headerValue) {
43 this.headerValue = headerValue;
44 }
45 /**
46 * @return Value for HTTP Header 'Sec-WebSocket-Version'
47 */
48 public String toHttpHeaderValue() {
49 return toAsciiString().toString();
50 }
51
52 AsciiString toAsciiString() {
53 return headerValue;
54 }
55 }