Skip to content

Commit

Permalink
fix(HTTPClient): add handling for 204: No Content responses
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
micgro42 committed Apr 13, 2018
1 parent 40bf4d4 commit 079e013
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion inc/HTTPClient.php
Expand Up @@ -442,7 +442,9 @@ function sendRequest($url,$data='',$method='GET'){
$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);
Expand Down

0 comments on commit 079e013

Please sign in to comment.