From 079e01378e7009bd792c96cc7b1652a6ebd051d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Fri, 13 Apr 2018 15:49:21 +0200 Subject: [PATCH] fix(HTTPClient): add handling for 204: No Content responses This fixes a bug that would occur if the DokuHTTPClient receives a 204 response, e.g. as a result for a request to delete something. It would still try to read the body, which fails, thus producing a timeout and finally throwing an exception. This fix instructs the HTTPClient to not read the (not existing) body if it receives a 204. --- inc/HTTPClient.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 7737878bd..e20b7d98f 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -442,7 +442,9 @@ class HTTPClient { $r_body = $this->_readData($socket, $length, 'response (content-length limited)', true); }elseif( !isset($this->resp_headers['transfer-encoding']) && $this->max_bodysize && !$this->keep_alive){ $r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true); - }else{ + } elseif ((int)$this->status === 204) { + // request has no content + } else{ // read entire socket while (!feof($socket)) { $r_body .= $this->_readData($socket, 4096, 'response (unlimited)', true); -- GitLab