Mark data as sent. Args: data: Bytes to send end_stream: True if this completes the response Raises: HTTP2StreamError: If data cannot be sent in current state
(self, data, end_stream=False)
| 198 | self.response_complete = True |
| 199 | |
| 200 | def send_data(self, data, end_stream=False): |
| 201 | """Mark data as sent. |
| 202 | |
| 203 | Args: |
| 204 | data: Bytes to send |
| 205 | end_stream: True if this completes the response |
| 206 | |
| 207 | Raises: |
| 208 | HTTP2StreamError: If data cannot be sent in current state |
| 209 | """ |
| 210 | if not self.can_send: |
| 211 | raise HTTP2StreamError( |
| 212 | self.stream_id, |
| 213 | f"Cannot send data in state {self.state.name}" |
| 214 | ) |
| 215 | |
| 216 | if end_stream: |
| 217 | self._half_close_local() |
| 218 | self.response_complete = True |
| 219 | |
| 220 | def send_trailers(self, trailers): |
| 221 | """Mark trailers as sent and close the stream. |