我正在寫一個多線程的PHP客戶端,使https請求到apache反向代理並測量一些統計數據。我正在撰寫關於通過TLS會話恢復提高性能的學士論文。現在我需要做一個證明/證明這一點的概念證明。目前,我有這樣的代碼:在TLS會話恢復在PHP
$this->synchronized(function($this){
$this->before = microtime(true);
}, $this);
$url = 'https://192.168.0.171/';
# Some dummy data
$data = array('name' => 'Nicolas', 'bank account' => '123462343');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
),
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
"ciphers" => "HIGH:!SSLv2:!SSLv3"
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$this->synchronized(function($this){
$this->after = microtime(true);
}, $this);
$this->counter_group->write($this->before, $this->after, $result);
此代碼的工作做一個完整的握手,但我似乎無法弄清楚如何在PHP做一個恢復握手?
任何幫助將不勝感激!
......或反駁。 :) – bishop
file_get_contents()通常在請求...之後立即關閉TCP連接。需要保持活着的連接頭和fopen()的句柄...我可惜沒有足夠的時間來調查現在: -/ – bwoebi