Commit f873315
net.http: bring H2Conn.read_response to response-validation parity with the mux path
The synchronous client validated far less of a server response than the
multiplexed H2MuxConn.on_response_headers/on_response_data path, so a malformed
server could hang the request or have a bogus response accepted. Close the gaps,
matching the mux path (which already enforces each of these):
- Trailers (a second HEADERS block) must carry END_STREAM (RFC 9113 §8.1).
Previously a trailers frame without END_STREAM fell through and read_response
looped in next_frame() forever.
- :status must be present and in range; 101 is forbidden in HTTP/2 (§8.1.1,
§8.3.1). Previously a sub-100 or >599 status was latched as a valid response,
and 101 was treated as a 1xx interim, waiting forever for a "final" HEADERS.
- DATA before the first response HEADERS is a protocol error (§8.1). Previously
body bytes were delivered with status 0.
The 1xx + END_STREAM rejection added in the previous commit is retained. Each
guard fails the request (abandoning the connection) rather than hanging or
returning a malformed response, consistent with the existing error returns in
read_response. Surfaced while reviewing the 1xx fix for #27413.
Co-Authored-By: WOZCODE <contact@withwoz.com>1 parent 0c61bdd commit f873315
1 file changed
Lines changed: 36 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
205 | 221 | | |
| 222 | + | |
206 | 223 | | |
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
210 | 227 | | |
211 | 228 | | |
212 | 229 | | |
| 230 | + | |
213 | 231 | | |
214 | 232 | | |
215 | 233 | | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
216 | 241 | | |
217 | 242 | | |
218 | 243 | | |
| |||
227 | 252 | | |
228 | 253 | | |
229 | 254 | | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 255 | + | |
| 256 | + | |
234 | 257 | | |
235 | 258 | | |
236 | 259 | | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
| 260 | + | |
241 | 261 | | |
242 | 262 | | |
243 | 263 | | |
| |||
256 | 276 | | |
257 | 277 | | |
258 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
259 | 285 | | |
260 | 286 | | |
261 | 287 | | |
| |||
0 commit comments