aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorPedro J. Estébanez2018-04-18 20:50:31 +0200
committerPedro J. Estébanez2018-05-22 15:08:31 +0200
commit2587fcccee3b9ee2b934f681f9f3ff921edf096f (patch)
tree67927ded3979a151808489b0dcd8fa556aec1736 /drivers
parentb22f048700105dec26154cc90f10b0ef34b3f5ed (diff)
downloadgodot-2587fcccee3b9ee2b934f681f9f3ff921edf096f.tar.gz
godot-2587fcccee3b9ee2b934f681f9f3ff921edf096f.tar.zst
godot-2587fcccee3b9ee2b934f681f9f3ff921edf096f.zip
Allow body-up-to-EOF HTTP responses
Implements the same heuristic as Curl (and web browsers): if no `Content-Length`, no `Connection: keep-alive` and no chunked transfer encoding, assume th rest of the data until EOF is the body, gracefully setting the HTTP client back to the disconnected state. Theoretically, this is not compliant with HTTP 1.1, by which `keep-alive` is the default, but in practice, an explicit header is sent by servers.
Diffstat (limited to '')
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp1
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index 17112e5ab..b19bdc460 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -290,6 +290,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received,
status = STATUS_NONE;
peer_port = 0;
peer_host = IP_Address();
+ r_received = total_read;
return ERR_FILE_EOF;
} else {
diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp
index 55775fc23..2faf3f377 100644
--- a/drivers/windows/stream_peer_tcp_winsock.cpp
+++ b/drivers/windows/stream_peer_tcp_winsock.cpp
@@ -212,6 +212,7 @@ Error StreamPeerTCPWinsock::read(uint8_t *p_buffer, int p_bytes, int &r_received
_block(sockfd, true, false);
} else if (read == 0) {
disconnect_from_host();
+ r_received = total_read;
return ERR_FILE_EOF;
} else {