View Javadoc
1   /*
2    * Copyright 2015 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  
17  package io.netty.handler.codec.http2;
18  
19  import io.netty.handler.codec.http.HttpScheme;
20  import io.netty.handler.codec.http2.Http2HeadersEncoder.SensitivityDetector;
21  
22  /**
23   * Builder which builds {@link HttpToHttp2ConnectionHandler} objects.
24   */
25  public final class HttpToHttp2ConnectionHandlerBuilder extends
26          AbstractHttp2ConnectionHandlerBuilder<HttpToHttp2ConnectionHandler, HttpToHttp2ConnectionHandlerBuilder> {
27  
28      private HttpScheme httpScheme;
29  
30      @Override
31      public HttpToHttp2ConnectionHandlerBuilder validateHeaders(boolean validateHeaders) {
32          return super.validateHeaders(validateHeaders);
33      }
34  
35      @Override
36      public HttpToHttp2ConnectionHandlerBuilder initialSettings(Http2Settings settings) {
37          return super.initialSettings(settings);
38      }
39  
40      @Override
41      public HttpToHttp2ConnectionHandlerBuilder frameListener(Http2FrameListener frameListener) {
42          return super.frameListener(frameListener);
43      }
44  
45      @Override
46      public HttpToHttp2ConnectionHandlerBuilder gracefulShutdownTimeoutMillis(long gracefulShutdownTimeoutMillis) {
47          return super.gracefulShutdownTimeoutMillis(gracefulShutdownTimeoutMillis);
48      }
49  
50      @Override
51      public HttpToHttp2ConnectionHandlerBuilder server(boolean isServer) {
52          return super.server(isServer);
53      }
54  
55      @Override
56      public HttpToHttp2ConnectionHandlerBuilder connection(Http2Connection connection) {
57          return super.connection(connection);
58      }
59  
60      @Override
61      public HttpToHttp2ConnectionHandlerBuilder codec(Http2ConnectionDecoder decoder,
62                                                       Http2ConnectionEncoder encoder) {
63          return super.codec(decoder, encoder);
64      }
65  
66      @Override
67      public HttpToHttp2ConnectionHandlerBuilder frameLogger(Http2FrameLogger frameLogger) {
68          return super.frameLogger(frameLogger);
69      }
70  
71      @Override
72      public HttpToHttp2ConnectionHandlerBuilder encoderEnforceMaxConcurrentStreams(
73              boolean encoderEnforceMaxConcurrentStreams) {
74          return super.encoderEnforceMaxConcurrentStreams(encoderEnforceMaxConcurrentStreams);
75      }
76  
77      @Override
78      public HttpToHttp2ConnectionHandlerBuilder headerSensitivityDetector(
79              SensitivityDetector headerSensitivityDetector) {
80          return super.headerSensitivityDetector(headerSensitivityDetector);
81      }
82  
83      @Override
84      @Deprecated
85      public HttpToHttp2ConnectionHandlerBuilder initialHuffmanDecodeCapacity(int initialHuffmanDecodeCapacity) {
86          return super.initialHuffmanDecodeCapacity(initialHuffmanDecodeCapacity);
87      }
88  
89      @Override
90      public HttpToHttp2ConnectionHandlerBuilder decoupleCloseAndGoAway(boolean decoupleCloseAndGoAway) {
91          return super.decoupleCloseAndGoAway(decoupleCloseAndGoAway);
92      }
93  
94      @Override
95      public HttpToHttp2ConnectionHandlerBuilder flushPreface(boolean flushPreface) {
96          return super.flushPreface(flushPreface);
97      }
98  
99      /**
100      * Add {@code scheme} in {@link Http2Headers} if not already present.
101      *
102      * @param httpScheme {@link HttpScheme} type
103      * @return {@code this}.
104      */
105     public HttpToHttp2ConnectionHandlerBuilder httpScheme(HttpScheme httpScheme) {
106         this.httpScheme = httpScheme;
107         return self();
108     }
109 
110     @Override
111     public HttpToHttp2ConnectionHandler build() {
112         return super.build();
113     }
114 
115     @Override
116     protected HttpToHttp2ConnectionHandler build(Http2ConnectionDecoder decoder, Http2ConnectionEncoder encoder,
117                                                  Http2Settings initialSettings) {
118         return new HttpToHttp2ConnectionHandler(decoder, encoder, initialSettings, isValidateHeaders(),
119                 decoupleCloseAndGoAway(), flushPreface(), httpScheme);
120     }
121 }