查看本类的 API文档回源码主页即时通讯网 - 即时通讯开发者社区!
1   /*
2    * Copyright 2019 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  // (BSD License: https://www.opensource.org/licenses/bsd-license)
17  //
18  // Copyright (c) 2011, Joe Walnes and contributors
19  // All rights reserved.
20  //
21  // Redistribution and use in source and binary forms, with or
22  // without modification, are permitted provided that the
23  // following conditions are met:
24  //
25  // * Redistributions of source code must retain the above
26  // copyright notice, this list of conditions and the
27  // following disclaimer.
28  //
29  // * Redistributions in binary form must reproduce the above
30  // copyright notice, this list of conditions and the
31  // following disclaimer in the documentation and/or other
32  // materials provided with the distribution.
33  //
34  // * Neither the name of the Webbit nor the names of
35  // its contributors may be used to endorse or promote products
36  // derived from this software without specific prior written
37  // permission.
38  //
39  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
40  // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
41  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
42  // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
44  // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
45  // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
46  // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
47  // GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
48  // BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
49  // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50  // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
51  // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52  // POSSIBILITY OF SUCH DAMAGE.
53  
54  package io.netty.handler.codec.http.websocketx;
55  
56  /**
57   * Decodes a web socket frame from wire protocol version 13 format. V13 is essentially the same as V8.
58   */
59  public class WebSocket13FrameDecoder extends WebSocket08FrameDecoder {
60  
61      /**
62       * Constructor
63       *
64       * @param expectMaskedFrames
65       *            Web socket servers must set this to true processed incoming masked payload. Client implementations
66       *            must set this to false.
67       * @param allowExtensions
68       *            Flag to allow reserved extension bits to be used or not
69       * @param maxFramePayloadLength
70       *            Maximum length of a frame's payload. Setting this to an appropriate value for you application
71       *            helps check for denial of services attacks.
72       */
73      public WebSocket13FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength) {
74          this(expectMaskedFrames, allowExtensions, maxFramePayloadLength, false);
75      }
76  
77      /**
78       * Constructor
79       *
80       * @param expectMaskedFrames
81       *            Web socket servers must set this to true processed incoming masked payload. Client implementations
82       *            must set this to false.
83       * @param allowExtensions
84       *            Flag to allow reserved extension bits to be used or not
85       * @param maxFramePayloadLength
86       *            Maximum length of a frame's payload. Setting this to an appropriate value for you application
87       *            helps check for denial of services attacks.
88       * @param allowMaskMismatch
89       *            When set to true, frames which are not masked properly according to the standard will still be
90       *            accepted.
91       */
92      public WebSocket13FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength,
93                                     boolean allowMaskMismatch) {
94          this(WebSocketDecoderConfig.newBuilder()
95              .expectMaskedFrames(expectMaskedFrames)
96              .allowExtensions(allowExtensions)
97              .maxFramePayloadLength(maxFramePayloadLength)
98              .allowMaskMismatch(allowMaskMismatch)
99              .build());
100     }
101 
102     /**
103      * Constructor
104      *
105      * @param decoderConfig
106      *            Frames decoder configuration.
107      */
108     public WebSocket13FrameDecoder(WebSocketDecoderConfig decoderConfig) {
109         super(decoderConfig);
110     }
111 }