1 //
2 // ========================================================================
3 // Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 // ------------------------------------------------------------------------
5 // All rights reserved. This program and the accompanying materials
6 // are made available under the terms of the Eclipse Public License v1.0
7 // and Apache License v2.0 which accompanies this distribution.
8 //
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
11 //
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
14 //
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
17 //
18
19 package org.eclipse.jetty.http2;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 /**
25 * Standard HTTP/2 error codes.
26 */
27 public enum ErrorCode
28 {
29 /**
30 * Indicates no errors.
31 */
32 NO_ERROR(0),
33 /**
34 * Indicates a generic HTTP/2 protocol violation.
35 */
36 PROTOCOL_ERROR(1),
37 /**
38 * Indicates an internal error.
39 */
40 INTERNAL_ERROR(2),
41 /**
42 * Indicates a HTTP/2 flow control violation.
43 */
44 FLOW_CONTROL_ERROR(3),
45 /**
46 * Indicates that a SETTINGS frame did not receive a reply in a timely manner.
47 */
48 SETTINGS_TIMEOUT_ERROR(4),
49 /**
50 * Indicates that a stream frame has been received after the stream was closed.
51 */
52 STREAM_CLOSED_ERROR(5),
53 /**
54 * Indicates that a frame has an invalid length.
55 */
56 FRAME_SIZE_ERROR(6),
57 /**
58 * Indicates that a stream was rejected before application processing.
59 */
60 REFUSED_STREAM_ERROR(7),
61 /**
62 * Indicates that a stream is no longer needed.
63 */
64 CANCEL_STREAM_ERROR(8),
65 /**
66 * Indicates inability to maintain the HPACK compression context.
67 */
68 COMPRESSION_ERROR(9),
69 /**
70 * Indicates that the connection established by a HTTP CONNECT was abnormally closed.
71 */
72 HTTP_CONNECT_ERROR(10),
73 /**
74 * Indicates that the other peer might be generating excessive load.
75 */
76 ENHANCE_YOUR_CALM_ERROR(11),
77 /**
78 * Indicates that the transport properties do not meet minimum security requirements.
79 */
80 INADEQUATE_SECURITY_ERROR(12),
81 /**
82 * Indicates that HTTP/1.1 must be used rather than HTTP/2.
83 */
84 HTTP_1_1_REQUIRED_ERROR(13);
85
86 public final int code;
87
88 private ErrorCode(int code)
89 {
90 this.code = code;
91 Codes.codes.put(code, this);
92 }
93
94 public static ErrorCode from(int error)
95 {
96 return Codes.codes.get(error);
97 }
98
99 private static class Codes
100 {
101 private static final Map<Integer, ErrorCode> codes = new HashMap<>();
102 }
103 }