Commit 5b5a91c
authored
fix: recover HTTP/2 handler errors as 500 (#1041)
Motivation:
Port upstream akka-http fix 02bb9872e1d391f53e21b663336e5052085a0b8c, which is now Apache licensed. HTTP/2 user handler failures should be converted into 500 responses instead of leaking through the connection handling path.
Modification:
Wrap HTTP/2 handlers with NonFatal error recovery for failed futures and synchronous throws. Keep HTTP/1 fallback on the original handler so existing HTTP/1 error classification is preserved, and reject unknown HTTP/2 pseudo-headers during request parsing so protocol errors are not converted to 500 responses.
Result:
HTTP/2 handler failures now return InternalServerError while malformed pseudo-headers still produce HTTP/2 protocol errors. Added regression coverage for failed futures, synchronous throws, and verified h2spec pseudo-header behavior.
References:
Upstream: akka/akka-http@02bb9871 parent 0b6bca0 commit 5b5a91c
3 files changed
Lines changed: 57 additions & 6 deletions
File tree
- http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2
- http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
93 | 95 | | |
94 | | - | |
| 96 | + | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | | - | |
| 100 | + | |
| 101 | + | |
98 | 102 | | |
99 | 103 | | |
100 | 104 | | |
| |||
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
141 | 162 | | |
142 | 163 | | |
143 | 164 | | |
| |||
149 | 170 | | |
150 | 171 | | |
151 | 172 | | |
| 173 | + | |
152 | 174 | | |
153 | 175 | | |
154 | 176 | | |
| |||
172 | 194 | | |
173 | 195 | | |
174 | 196 | | |
175 | | - | |
176 | | - | |
| 197 | + | |
| 198 | + | |
177 | 199 | | |
178 | 200 | | |
179 | 201 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
163 | 166 | | |
164 | 167 | | |
165 | 168 | | |
| |||
Lines changed: 28 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| 47 | + | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
144 | 145 | | |
145 | 146 | | |
146 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
147 | 173 | | |
148 | 174 | | |
149 | 175 | | |
| |||
169 | 195 | | |
170 | 196 | | |
171 | 197 | | |
172 | | - | |
| 198 | + | |
173 | 199 | | |
174 | 200 | | |
175 | 201 | | |
| |||
0 commit comments