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