Repository navigation
Tags
Tags
Improve streaming response handling (#10) * add bad response to test server * add broken response to test server, add failing test * Map pycurl E_PARTIAL_FILE error to httpx.RemoteProtocolError When a server closes the connection before sending the full Content-Length, pycurl returns error code 18 (E_PARTIAL_FILE). Map this to httpx.RemoteProtocolError for consistent behavior with httpx's native AsyncHTTPTransport. Update test_response_closed_early to expect RemoteProtocolError instead of silently consuming partial data. The test now validates that both transports properly signal protocol violations when Content-Length mismatches occur. * accept RemoteProtocolError only in test * check for expected partial response * Allow partial response data before streaming error is raised When a transfer fails (e.g., connection closes mid-stream, partial file error), defer raising the exception until the consumer tries to read more data. This allows partial data that was already received via write_callback to be consumed before the error is signaled. Key changes: - Catch pycurl.error in perform() and store it as perform_error - Queue the error in the async stream before the END_OF_STREAM sentinel - Check for Exception type in _AsyncQueueStream.__aiter__() to raise queued errors - Only raise immediately if no response started (status_code == 0) or for non-streaming This enables behavior like httpx's AsyncHTTPTransport where partial responses can be read even when Content-Length mismatches indicate a protocol error. For test_response_closed_early: - Both transports now properly signal protocol errors via stream iteration - Partial data is readable before the error is raised - Test validates that pycurl behavior matches httpx behavior * always expect partial response; remove unused timer