diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/io/http_client.cpp | 33 | ||||
-rw-r--r-- | core/io/stream_peer_tcp.cpp | 31 | ||||
-rw-r--r-- | core/math/octree.h | 2 | ||||
-rw-r--r-- | core/math/triangulate.cpp | 2 | ||||
-rw-r--r-- | core/os/dir_access.h | 2 | ||||
-rw-r--r-- | core/os/os.h | 2 | ||||
-rw-r--r-- | core/project_settings.cpp | 2 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 5 | ||||
-rw-r--r-- | core/variant_parser.cpp | 4 |
9 files changed, 47 insertions, 36 deletions
diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index c47ae05dc2..de0b6860f9 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -275,7 +275,7 @@ void HTTPClient::close() { response_headers.clear(); response_str.clear(); - body_size = 0; + body_size = -1; body_left = 0; chunk_left = 0; read_until_eof = false; @@ -349,7 +349,7 @@ Error HTTPClient::poll() { } if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) { - // Handshake has been successfull + // Handshake has been successful handshaking = false; status = STATUS_CONNECTED; return OK; @@ -404,7 +404,7 @@ Error HTTPClient::poll() { String response; response.parse_utf8((const char *)response_str.ptr()); Vector<String> responses = response.split("\n"); - body_size = 0; + body_size = -1; chunked = false; body_left = 0; chunk_left = 0; @@ -448,7 +448,7 @@ Error HTTPClient::poll() { } } - if (body_size || chunked) { + if (body_size != -1 || chunked) { status = STATUS_BODY; } else if (!keep_alive) { @@ -665,11 +665,24 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received if (blocking) { - Error err = connection->get_data(p_buffer, p_bytes); - if (err == OK) - r_received = p_bytes; - else - r_received = 0; + // We can't use StreamPeer.get_data, since when reaching EOF we will get an + // error without knowing how many bytes we received. + Error err = ERR_FILE_EOF; + int read; + int left = p_bytes; + r_received = 0; + while (left > 0) { + err = connection->get_partial_data(p_buffer, left, read); + if (err == OK) { + r_received += read; + } else if (err == ERR_FILE_EOF) { + r_received += read; + return err; + } else { + return err; + } + left -= read; + } return err; } else { return connection->get_partial_data(p_buffer, p_bytes, r_received); @@ -687,7 +700,7 @@ HTTPClient::HTTPClient() { resolving = IP::RESOLVER_INVALID_ID; status = STATUS_DISCONNECTED; conn_port = -1; - body_size = 0; + body_size = -1; chunked = false; body_left = 0; read_until_eof = false; diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 484e160f0e..f4bf8a13ae 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -44,6 +44,7 @@ Error StreamPeerTCP::_poll_connection() { return OK; } + disconnect_from_host(); status = STATUS_ERROR; return ERR_CONNECTION_ERROR; } @@ -75,17 +76,16 @@ Error StreamPeerTCP::connect_to_host(const IP_Address &p_host, uint16_t p_port) err = _sock->connect_to_host(p_host, p_port); - if (err != OK) { - if (err == ERR_BUSY) { - status = STATUS_CONNECTING; - } else { - ERR_PRINT("Connection to remote host failed!"); - disconnect_from_host(); - return FAILED; - } + if (err == OK) { + status = STATUS_CONNECTED; + } else if (err == ERR_BUSY) { + status = STATUS_CONNECTING; + } else { + ERR_PRINT("Connection to remote host failed!"); + disconnect_from_host(); + return FAILED; } - status = STATUS_CONNECTED; peer_host = p_host; peer_port = p_port; @@ -163,20 +163,20 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool if (!is_connected_to_host()) { return FAILED; - }; + } if (status == STATUS_CONNECTING) { if (_poll_connection() != OK) { return FAILED; - }; + } if (status != STATUS_CONNECTED) { r_received = 0; return OK; - }; - }; + } + } Error err; int to_read = p_bytes; @@ -209,10 +209,7 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool } else if (read == 0) { - _sock->close(); - status = STATUS_NONE; - peer_port = 0; - peer_host = IP_Address(); + disconnect_from_host(); r_received = total_read; return ERR_FILE_EOF; diff --git a/core/math/octree.h b/core/math/octree.h index b57fb84e8f..cd89743a5a 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -478,7 +478,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct splits++; } } else { - /* check againt AABB where child should be */ + /* check against AABB where child should be */ AABB aabb = p_octant->aabb; aabb.size *= 0.5; diff --git a/core/math/triangulate.cpp b/core/math/triangulate.cpp index 0edc0ea039..69ffc95946 100644 --- a/core/math/triangulate.cpp +++ b/core/math/triangulate.cpp @@ -186,7 +186,7 @@ bool Triangulate::triangulate(const Vector<Vector2> &contour, Vector<int> &resul nv--; - /* resest error detection counter */ + /* reset error detection counter */ count = 2 * nv; } } diff --git a/core/os/dir_access.h b/core/os/dir_access.h index 6b391a87fa..773f0bcd41 100644 --- a/core/os/dir_access.h +++ b/core/os/dir_access.h @@ -38,7 +38,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ -//@ TOOD, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies +//@ TODO, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies class DirAccess { public: enum AccessType { diff --git a/core/os/os.h b/core/os/os.h index 8fb5b45f67..7786ffb26e 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -129,7 +129,7 @@ protected: RenderThreadMode _render_thread_mode; - // functions used by main to initialize/deintialize the OS + // functions used by main to initialize/deinitialize the OS void add_logger(Logger *p_logger); virtual void initialize_core() = 0; diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 04e09fb12e..99a23bbee1 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -60,7 +60,7 @@ String ProjectSettings::get_resource_path() const { String ProjectSettings::localize_path(const String &p_path) const { if (resource_path == "") - return p_path; //not initialied yet + return p_path; //not initialized yet if (p_path.begins_with("res://") || p_path.begins_with("user://") || (p_path.is_abs_path() && !p_path.begins_with(resource_path))) diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 0519807e63..704b4d1fdc 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -77,18 +77,19 @@ Error ScriptDebuggerRemote::connect_to_host(const String &p_host, uint16_t p_por for (int i = 0; i < tries; i++) { if (tcp_client->get_status() == StreamPeerTCP::STATUS_CONNECTED) { + print_verbose("Remote Debugger: Connected!"); break; } else { const int ms = waits[i]; OS::get_singleton()->delay_usec(ms * 1000); - ERR_PRINTS("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in " + String::num(ms) + " msec."); + print_verbose("Remote Debugger: Connection failed with status: '" + String::num(tcp_client->get_status()) + "', retrying in " + String::num(ms) + " msec."); }; }; if (tcp_client->get_status() != StreamPeerTCP::STATUS_CONNECTED) { - ERR_PRINTS("Remote Debugger: Unable to connect."); + ERR_PRINTS("Remote Debugger: Unable to connect. Status: " + String::num(tcp_client->get_status())); return FAILED; }; diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 2c45c6b3ed..3d5ae74e92 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1429,10 +1429,10 @@ Error VariantParser::_parse_tag(Token &token, Stream *p_stream, int &line, Strin break; if (parsing_tag && token.type == TK_PERIOD) { - r_tag.name += "."; //support tags such as [someprop.Anroid] for specific platforms + r_tag.name += "."; //support tags such as [someprop.Android] for specific platforms get_token(p_stream, token, line, r_err_str); } else if (parsing_tag && token.type == TK_COLON) { - r_tag.name += ":"; //support tags such as [someprop.Anroid] for specific platforms + r_tag.name += ":"; //support tags such as [someprop.Android] for specific platforms get_token(p_stream, token, line, r_err_str); } else { parsing_tag = false; |