View Javadoc
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 7 format. V7 is essentially the same as V8.
58   */
59  public class WebSocket07FrameDecoder 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 WebSocket07FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength) {
74          this(WebSocketDecoderConfig.newBuilder()
75              .expectMaskedFrames(expectMaskedFrames)
76              .allowExtensions(allowExtensions)
77              .maxFramePayloadLength(maxFramePayloadLength)
78              .build());
79      }
80  
81      /**
82       * Constructor
83       *
84       * @param expectMaskedFrames
85       *            Web socket servers must set this to true processed incoming masked payload. Client implementations
86       *            must set this to false.
87       * @param allowExtensions
88       *            Flag to allow reserved extension bits to be used or not
89       * @param maxFramePayloadLength
90       *            Maximum length of a frame's payload. Setting this to an appropriate value for you application
91       *            helps check for denial of services attacks.
92       * @param allowMaskMismatch
93       *            When set to true, frames which are not masked properly according to the standard will still be
94       *            accepted.
95       */
96      public WebSocket07FrameDecoder(boolean expectMaskedFrames, boolean allowExtensions, int maxFramePayloadLength,
97                                     boolean allowMaskMismatch) {
98          this(WebSocketDecoderConfig.newBuilder()
99              .expectMaskedFrames(expectMaskedFrames)
100             .allowExtensions(allowExtensions)
101             .maxFramePayloadLength(maxFramePayloadLength)
102             .allowMaskMismatch(allowMaskMismatch)
103             .build());
104     }
105 
106     /**
107      * Constructor
108      *
109      * @param decoderConfig
110      *            Frames decoder configuration.
111      */
112     public WebSocket07FrameDecoder(WebSocketDecoderConfig decoderConfig) {
113         super(decoderConfig);
114     }
115 }