Skip to content

Commit b2c34c1

Browse files
committed
Merge branch 'devel' into connection_tests_close_and_keep-alive
# Conflicts: # tests/ConnectionTest.php
2 parents 7593bda + 121bebf commit b2c34c1

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

lib/ArangoDBClient/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ private function executeRequest($method, $url, $data, array $customHeaders = [])
458458
$startTime = microtime(true);
459459
}
460460

461-
$result = HttpHelper::transfer($handle, $request);
461+
$result = HttpHelper::transfer($handle, $request, $method);
462462

463463
if ($traceFunc) {
464464
// only issue syscall if we need it

lib/ArangoDBClient/HttpHelper.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,12 @@ public static function validateMethod($method)
207207
*
208208
* @param resource $socket - connection socket (must be open)
209209
* @param string $request - complete HTTP request as a string
210+
* @param string $method - HTTP method used (e.g. "HEAD")
210211
*
211212
* @throws ClientException
212213
* @return string - HTTP response string as provided by the server
213214
*/
214-
public static function transfer($socket, $request)
215+
public static function transfer($socket, $request, $method)
215216
{
216217
if (!is_resource($socket)) {
217218
throw new ClientException('Invalid socket used');
@@ -255,6 +256,13 @@ public static function transfer($socket, $request)
255256
if ($pos !== false) {
256257
$contentLength = (int) substr($result, $pos + 16, 10); // 16 = strlen("content-length: ")
257258
$contentLengthPos = $pos + 17; // 17 = 16 + 1 one digit
259+
260+
if ($method === "HEAD") {
261+
// for HTTP HEAD requests, the server will respond
262+
// with the proper Content-Length value, but will
263+
// NOT return the body.
264+
$contentLength = 0;
265+
}
258266
}
259267
}
260268

tests/CollectionExtendedTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public function testCreateRenameAndDeleteCollectionWithWrongEncoding()
338338
// inject wrong encoding
339339
$isoValue = iconv('UTF-8', 'ISO-8859-1//TRANSLIT', 'ArangoDB_PHP_TestSuite_TestCollection_01_renamedü');
340340

341-
$collectionHandler->rename($resultingCollection, $isoValue);
341+
static::assertTrue($collectionHandler->rename($resultingCollection, $isoValue));
342342

343343

344344
$response = $collectionHandler->drop($resultingCollection);

tests/DocumentBasicTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public function setUp()
2727
{
2828
$this->connection = getConnection();
2929
$this->collectionHandler = new CollectionHandler($this->connection);
30+
31+
try {
32+
$this->collectionHandler->drop('ArangoDB_PHP_TestSuite_TestCollection_01');
33+
} catch (\Exception $e) {
34+
// don't bother us, if it's already deleted.
35+
}
36+
3037
$this->collection = new Collection();
3138
$this->collection->setName('ArangoDB_PHP_TestSuite_TestCollection_01');
3239
$this->collectionHandler->create($this->collection);

0 commit comments

Comments
 (0)