Skip to content

Revert "Fix compatibility with Windows" #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions httpstat.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ public function get($default = null)


$curlFormat = '{' .
'\"time_namelookup\": %{time_namelookup},' .
'\"time_connect\": %{time_connect},' .
'\"time_appconnect\": %{time_appconnect},' .
'\"time_pretransfer\": %{time_pretransfer},' .
'\"time_redirect\": %{time_redirect},' .
'\"time_starttransfer\": %{time_starttransfer},' .
'\"time_total\": %{time_total},' .
'\"speed_download\": %{speed_download},' .
'\"speed_upload\": %{speed_upload}' .
'"time_namelookup": %{time_namelookup},' .
'"time_connect": %{time_connect},' .
'"time_appconnect": %{time_appconnect},' .
'"time_pretransfer": %{time_pretransfer},' .
'"time_redirect": %{time_redirect},' .
'"time_starttransfer": %{time_starttransfer},' .
'"time_total": %{time_total},' .
'"speed_download": %{speed_download},' .
'"speed_upload": %{speed_upload}' .
'}';


Expand All @@ -68,7 +68,8 @@ public function get($default = null)
";


$ISATTY = function_exists('posix_isatty') ? posix_isatty(STDOUT) : true;
$ISATTY = posix_isatty(STDOUT);


function makeColor($code)
{
Expand Down Expand Up @@ -140,7 +141,7 @@ function printHelp()
which are already used internally.
-h --help show this screen.
--version show version.

Environments:
HTTPSTAT_SHOW_BODY Set to `true` to show resposne body in the output,
note that body length is limited to 1023 bytes, will be
Expand Down Expand Up @@ -236,20 +237,14 @@ function main()
fclose($headerF);

// run cmd
if (strcasecmp(substr(PHP_OS, 0, 3), 'WIN') != 0) {
// unix like systems
$cmdEnv = $_ENV;
$cmdEnv['LC_ALL'] = 'C';
}
else
// windows
$cmdEnv = null;
$cmdEnv = $_ENV;
$cmdEnv['LC_ALL'] = 'C';

$cmdArr = array(
$curlBin,
'-w', "\"{$curlFormat}\"",
'-D', "\"{$headerFName}\"",
'-o', "\"{$bodyFName}\"",
'-w', "'{$curlFormat}'",
'-D', "'{$headerFName}'",
'-o', "'{$bodyFName}'",
'-s', '-S'
);

Expand All @@ -262,16 +257,13 @@ function main()

$p = proc_open($cmd,
array(
0 => array("pipe", "r"),
1 => array("pipe", "w"),
2 => array("pipe", "w")
array("pipe", "r"),
array("pipe", "w"),
array("pipe", "w")
),
$pipes,
sys_get_temp_dir(),
null,//$cmdEnv,
[
//'bypass_shell' => true,
]);
$cmdEnv);

$out = stream_get_contents($pipes[1]);
$err = stream_get_contents($pipes[2]);
Expand Down