Send an informational response (1xx) on a stream. This is used for 103 Early Hints and other 1xx responses. Informational responses are sent before the final response and do not end the stream. Args: stream_id: The stream ID status: HTTP stat
(self, stream_id, status, headers)
| 357 | ) |
| 358 | |
| 359 | def send_informational(self, stream_id, status, headers): |
| 360 | """Send an informational response (1xx) on a stream. |
| 361 | |
| 362 | This is used for 103 Early Hints and other 1xx responses. |
| 363 | Informational responses are sent before the final response |
| 364 | and do not end the stream. |
| 365 | |
| 366 | Args: |
| 367 | stream_id: The stream ID |
| 368 | status: HTTP status code (100-199) |
| 369 | headers: List of (name, value) header tuples |
| 370 | |
| 371 | Raises: |
| 372 | HTTP2Error: If status is not in 1xx range |
| 373 | """ |
| 374 | if status < 100 or status >= 200: |
| 375 | raise HTTP2Error(f"Invalid informational status: {status}") |
| 376 | |
| 377 | stream = self.streams.get(stream_id) |
| 378 | if stream is None: |
| 379 | raise HTTP2Error(f"Stream {stream_id} not found") |
| 380 | |
| 381 | # Build headers with :status pseudo-header |
| 382 | response_headers = [(':status', str(status))] |
| 383 | for name, value in headers: |
| 384 | # HTTP/2 headers must be lowercase |
| 385 | response_headers.append((name.lower(), str(value))) |
| 386 | |
| 387 | # Send headers with end_stream=False (informational, more to follow) |
| 388 | self.h2_conn.send_headers(stream_id, response_headers, end_stream=False) |
| 389 | self._send_pending_data() |
| 390 | |
| 391 | def send_response(self, stream_id, status, headers, body=None): |
| 392 | """Send a response on a stream. |