Skip to content

Commit 1be25d0

Browse files
committed
Moved throwing an exception if $responsetring === "" , before the splitting(and parsing) of the response string.
1 parent 967c3fc commit 1be25d0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/ArangoDBClient/HttpResponse.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ class HttpResponse
8989
public function __construct($responseString, $originUrl = null, $originMethod = null, $wasAsync = false)
9090
{
9191
$this->_wasAsync = $wasAsync;
92+
if ($originUrl !== null && $originMethod !== null) {
93+
if ($responseString === '') {
94+
throw new ClientException(
95+
'Got no response from the server after request to '
96+
. $originMethod . ' ' . $originUrl . ' - Note: this may be a timeout issue'
97+
);
98+
}
99+
}
92100

93101
list($this->_header, $this->_body) = HttpHelper::parseHttpMessage($responseString, $originUrl, $originMethod);
94102
list($this->_httpCode, $this->_result, $this->_headers) = HttpHelper::parseHeaders($this->_header);
@@ -98,18 +106,11 @@ public function __construct($responseString, $originUrl = null, $originMethod =
98106
) {
99107
// got no response body!
100108
if ($originUrl !== null && $originMethod !== null) {
101-
if ($responseString === '') {
102-
throw new ClientException(
103-
'Got no response from the server after request to '
104-
. $originMethod . ' ' . $originUrl . ' - Note: this may be a timeout issue'
105-
);
106-
}
107109
throw new ClientException(
108110
'Got an invalid response from the server after request to '
109111
. $originMethod . ' ' . $originUrl
110112
);
111113
}
112-
113114
throw new ClientException('Got an invalid response from the server');
114115
}
115116
}

0 commit comments

Comments
 (0)