Skip to content

Commit 5d1a9e4

Browse files
authored
Merge pull request php-curl-class#435 from zachborboa/master
Clean up
2 parents 93c1224 + 0996917 commit 5d1a9e4

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/Curl/Curl.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ public function download($url, $mixed_filename)
304304
{
305305
if (is_callable($mixed_filename)) {
306306
$this->downloadCompleteFunction = $mixed_filename;
307-
$fh = tmpfile();
307+
$this->fileHandle = tmpfile();
308308
} else {
309309
$filename = $mixed_filename;
310310

@@ -322,17 +322,16 @@ public function download($url, $mixed_filename)
322322
$range = $first_byte_position . '-';
323323
$this->setOpt(CURLOPT_RANGE, $range);
324324
}
325-
$fh = fopen($download_filename, $mode);
325+
$this->fileHandle = fopen($download_filename, $mode);
326326

327327
// Move the downloaded temporary file to the destination save path.
328328
$this->downloadCompleteFunction = function ($fh) use ($download_filename, $filename) {
329329
rename($download_filename, $filename);
330330
};
331331
}
332332

333-
$this->setOpt(CURLOPT_FILE, $fh);
333+
$this->setOpt(CURLOPT_FILE, $this->fileHandle);
334334
$this->get($url);
335-
$this->downloadComplete($fh);
336335

337336
return ! $this->error;
338337
}

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2620,7 +2620,8 @@ public function testEmptyResponse()
26202620
$reflection_method->setAccessible(true);
26212621

26222622
$curl = new Curl();
2623-
$reflection_method->invoke($curl, $response);
2623+
$response_headers = $reflection_method->invoke($curl, $response);
2624+
$this->assertArrayHasKey('Status-Line', $response_headers);
26242625
}
26252626

26262627
public function testArrayToStringConversion()

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2461,9 +2461,13 @@ public function testAddCurl()
24612461
$curl->setOpt(CURLOPT_CUSTOMREQUEST, 'GET');
24622462
$curl->setOpt(CURLOPT_HTTPGET, true);
24632463

2464+
$complete_called = false;
24642465
$multi_curl = new MultiCurl();
2465-
$multi_curl->addCurl($curl);
2466+
$multi_curl->addCurl($curl)->complete(function ($instance) use (&$complete_called) {
2467+
$complete_called = true;
2468+
});
24662469
$multi_curl->start();
2470+
$this->assertTrue($complete_called);
24672471
}
24682472

24692473
public function testSequentialId()

0 commit comments

Comments
 (0)