ソケットからPOSTリクエストを実行するためにPHPを使用しています。php fread()関数は、各行の長さをプレフィックスにすることがあるのはなぜですか?
// open a socket connection on port 80
$fp = fsockopen($host, 80);
// send the request headers:
fwrite($fp, "POST $path HTTP/1.1\r\n");
fwrite($fp, "Host: $host\r\n");
fwrite($fp, "Referer: $referer\r\n");
fwrite($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fwrite($fp, "Content-length: ". strlen($data) ."\r\n");
fwrite($fp, "Connection: close\r\n\r\n");
fwrite($fp, $data);
$result = '';
while(!feof($fp)) {
// receive the results of the request
$result .= fread($fp, 5000);
}
ただし、応答の各行の先頭には、その長さが16進数で表示されているようです。なぜそれが起こっているのですか?私が投稿する例えば
、テストcgiスクリプト、その環境を返します。
BASH=/bin/bash
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
しかし、私のPHP関数はこれで終わる:
f
BASH=/bin/bash
69
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
10
BASH_ALIASES=()