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