forked from VKCOM/kphp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
156 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@ok | ||
<?php | ||
|
||
require_once 'kphp_tester_include.php'; | ||
|
||
$length = 0; | ||
|
||
function test_stream_options() { | ||
$c = curl_init("http://localhost:8080"); | ||
$page_info = 'phpinfo();'; | ||
$filename = "simple_page.php"; | ||
$cmd = "nohup php -S localhost:8080 ./$filename > /dev/null 2>&1 & echo $!"; | ||
$fh = fopen("file.txt", "w+"); | ||
|
||
$callback = function ($ch, $str) { | ||
global $length; | ||
$length += strlen($str); | ||
if ($length >= 100) return -1; | ||
return $length; | ||
}; | ||
|
||
// var_dump(curl_setopt($c, CURLOPT_WRITEHEADER, $fh)); | ||
// var_dump(curl_setopt($c, CURLOPT_HEADERFUNCTION, $callback)); | ||
var_dump(curl_setopt($c, CURLOPT_WRITEFUNCTION, $callback)); | ||
var_dump(curl_setopt($c, CURLOPT_FILE, $fh)); | ||
|
||
exec("touch $filename && echo \"<?php\" > .$filename"); | ||
exec("echo \"$page_info\" >> .$filename"); | ||
exec($cmd, $op); | ||
var_dump(curl_exec($c)); | ||
|
||
var_dump($fh); | ||
exec("kill $op[0]"); | ||
fwrite(fopen("./test.txt", "w+"), $fh); | ||
curl_close($c); | ||
exec("rm ./$filename"); | ||
} | ||
|
||
test_stream_options(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
@ok | ||
<?php | ||
|
||
require_once 'kphp_tester_include.php'; | ||
|
||
// this test is not ready yet | ||
|
||
function test_write_function_option() { | ||
$fhandle = "hello world\n"; | ||
$ch = curl_init(); | ||
$callback = function ($ch, $str) use ($fhandle) { | ||
$rval = fwrite($fhandle, $str); | ||
return $rval ?: 0; | ||
}; | ||
|
||
var_dump(curl_setopt($ch, CURLOPT_WRITEFUNCTION, $callback)); | ||
curl_close($ch); | ||
} | ||
|
||
function test_write_header_function_option() { | ||
$fhandle = "hello world\n"; | ||
$ch = curl_init(); | ||
$callback = function ($ch, $str) use ($fhandle) { | ||
$rval = fwrite($fhandle, $str); | ||
return $rval ?: 0; | ||
}; | ||
|
||
var_dump(curl_setopt($ch, CURLOPT_WRITEHEADER, $fhandle)); | ||
var_dump(curl_setopt($ch, CURLOPT_HEADERFUNCTION, $callback)); | ||
curl_close($ch); | ||
} | ||
|
||
function test_progress_function_option() { | ||
$ch = curl_init(); | ||
|
||
$callback = function ($resource,$download_size, $downloaded, $upload_size, $uploaded) | ||
{ | ||
if($download_size > 0) | ||
echo $downloaded / $download_size * 100; | ||
return 0; | ||
}; | ||
|
||
var_dump(curl_setopt($ch, CURLOPT_NOPROGRESS, false)); | ||
var_dump(curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $callback)); | ||
curl_close($ch); | ||
} | ||
|
||
function test_read_function_option() { | ||
$ch = curl_init(); | ||
|
||
$stream = fopen("php://stdin", "r"); // wont work in kphp | ||
|
||
$callback = function ($ch, $stream, $length) { | ||
$data = fread($stream, $length); | ||
var_dump($data); | ||
return ($data !== false) ? $data : ""; | ||
}; | ||
|
||
var_dump(curl_setopt($ch, CURLOPT_READFUNCTION, $callback)); | ||
var_dump(curl_setopt($ch, CURLOPT_INFILE, $stream)); | ||
curl_close($ch); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@ok | ||
<?php | ||
|
||
require_once 'kphp_tester_include.php'; | ||
|
||
function test_new_options() { | ||
$c = curl_init(); | ||
var_dump(curl_setopt($c, CURLOPT_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST | CURLSSLOPT_NO_PARTIALCHAIN)); | ||
var_dump(curl_setopt($c, CURLOPT_PROXY_SSL_OPTIONS, CURLSSLOPT_ALLOW_BEAST | CURLSSLOPT_NO_PARTIALCHAIN)); | ||
var_dump(curl_setopt($c, CURLOPT_UPKEEP_INTERVAL_MS, 10000)); | ||
var_dump(curl_setopt($c, CURLOPT_UPLOAD_BUFFERSIZE, 100000)); | ||
var_dump(curl_setopt($c, CURLOPT_SSL_EC_CURVES, "smth")); | ||
|
||
var_dump(curl_setopt($c, CURLOPT_MAIL_RCPT_ALLLOWFAILS, true)); | ||
var_dump(curl_setopt($c, CURLOPT_MAXAGE_CONN, 30)); | ||
var_dump(curl_setopt($c, CURLOPT_MAXFILESIZE_LARGE, 1 << 48)); | ||
var_dump(curl_setopt($c, CURLOPT_MAXLIFETIME_CONN, 30)); | ||
var_dump(curl_setopt($c, CURLOPT_SASL_AUTHZID, "Ursel")); | ||
curl_close($c); | ||
} | ||
|
||
// only for testing kphp with new libcurl version | ||
//test_new_options(); |
Oops, something went wrong.