LibRequests: Don't crash on requests without a read stream finishing

This can now happen due to the hostname not existing, as RS explicitly
performs DNS resolution before setting up the response pipe.
This commit is contained in:
Ali Mohammad Pur 2024-11-03 09:44:24 +01:00 committed by Ali Mohammad Pur
parent 7e20f4726f
commit 879ae94183
Notes: github-actions[bot] 2024-11-20 20:44:20 +00:00

View file

@ -123,7 +123,7 @@ void Request::set_up_internal_stream_data(DataReceived on_data_available)
};
m_internal_stream_data->on_finish = [this, user_on_finish = move(user_on_finish)]() {
if (!m_internal_stream_data->user_finish_called && m_internal_stream_data->read_stream->is_eof()) {
if (!m_internal_stream_data->user_finish_called && (!m_internal_stream_data->read_stream || m_internal_stream_data->read_stream->is_eof())) {
m_internal_stream_data->user_finish_called = true;
user_on_finish(m_internal_stream_data->total_size, m_internal_stream_data->network_error);
}