View Javadoc
1   /*
2    * Copyright 2016 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.buffer.api.Buffer;
19  import io.netty5.util.Resource;
20  import io.netty5.util.internal.UnstableApi;
21  
22  /**
23   * HTTP/2 GOAWAY frame.
24   *
25   * <p>The last stream identifier <em>must not</em> be set by the application, but instead the
26   * relative {@link #extraStreamIds()} should be used. The {@link #lastStreamId()} will only be
27   * set for incoming GOAWAY frames by the HTTP/2 codec.
28   *
29   * <p>Graceful shutdown as described in the HTTP/2 spec can be accomplished by calling
30   * {@code #setExtraStreamIds(Integer.MAX_VALUE)}.
31   */
32  @UnstableApi
33  public interface Http2GoAwayFrame extends Http2Frame, Resource<Http2GoAwayFrame> {
34      /**
35       * The reason for beginning closure of the connection. Represented as an HTTP/2 error code.
36       */
37      long errorCode();
38  
39      /**
40       * The number of IDs to reserve for the receiver to use while GOAWAY is in transit. This allows
41       * for new streams currently en route to still be created, up to a point, which allows for very
42       * graceful shutdown of both sides.
43       */
44      int extraStreamIds();
45  
46      /**
47       * Sets the number of IDs to reserve for the receiver to use while GOAWAY is in transit.
48       *
49       * @see #extraStreamIds
50       * @return {@code this}
51       */
52      Http2GoAwayFrame setExtraStreamIds(int extraStreamIds);
53  
54      /**
55       * Returns the last stream identifier if set, or {@code -1} else.
56       */
57      int lastStreamId();
58  
59      /**
60       * Optional debugging information describing cause the GOAWAY. Will not be {@code null}, but may
61       * be empty.
62       */
63      Buffer content();
64  
65      /**
66       * Produce a copy of this GOAWAY frame, which contain a copy of the frame {@linkplain #content() contents}.
67       *
68       * @return A copy of this GOAWAY frame.
69       */
70      Http2GoAwayFrame copy();
71  }