Browse Source

Disconnect while downloading

Previously if a disconnect occured while downloading a non recoverable error was displayed. This PR attempts to fix this by making sure `request_completed` signal is emitted with an `STATUS_CONNECTION_ERROR` response code.
Zak 5 years ago
parent
commit
70c39737db
1 changed files with 2 additions and 0 deletions
  1. 2 0
      scene/main/http_request.cpp

+ 2 - 0
scene/main/http_request.cpp

@@ -349,6 +349,8 @@ bool HTTPRequest::_update_connection() {
 			}
 			}
 
 
 			client->poll();
 			client->poll();
+			if (client->get_status() != HTTPClient::STATUS_BODY)
+				break; // State changed after this poll, will check at next iteration.
 
 
 			PoolByteArray chunk = client->read_response_body_chunk();
 			PoolByteArray chunk = client->read_response_body_chunk();
 			downloaded += chunk.size();
 			downloaded += chunk.size();