Process received DATA frame with streaming support. Args: data: Bytes received end_stream: True if END_STREAM flag is set Raises: HTTP2StreamError: If data received in invalid state
(self, data, end_stream=False)
| 127 | self.request_complete = True |
| 128 | |
| 129 | def receive_data(self, data, end_stream=False): |
| 130 | """Process received DATA frame with streaming support. |
| 131 | |
| 132 | Args: |
| 133 | data: Bytes received |
| 134 | end_stream: True if END_STREAM flag is set |
| 135 | |
| 136 | Raises: |
| 137 | HTTP2StreamError: If data received in invalid state |
| 138 | """ |
| 139 | if not self.can_receive: |
| 140 | raise HTTP2StreamError( |
| 141 | self.stream_id, |
| 142 | f"Cannot receive data in state {self.state.name}" |
| 143 | ) |
| 144 | |
| 145 | # Add to chunks queue for streaming reads |
| 146 | if data: |
| 147 | self._body_chunks.append(data) |
| 148 | if self._body_event: |
| 149 | self._body_event.set() |
| 150 | |
| 151 | # Also write to legacy BytesIO for compatibility |
| 152 | self.request_body.write(data) |
| 153 | |
| 154 | if end_stream: |
| 155 | self._half_close_remote() |
| 156 | self.request_complete = True |
| 157 | self._body_complete = True |
| 158 | if self._body_event: |
| 159 | self._body_event.set() |
| 160 | |
| 161 | def receive_trailers(self, trailers): |
| 162 | """Process received trailing headers. |