此脚本侦听IP /端口,并打算充当HTTP(S)代理.
对HTTP URL的请求工作正常,但我遇到了如何处理HTTPS请求的绊脚石,更具体地说,是客户端向代理发送CONNECT请求后的SSLv3握手.
我最接近的答案是:
我真的不确定,所以关于如何处理这个的指针将非常感激.
以下是一个示例请求:http://pastebin.com/xkWhGyjW
<?php
class proxy {
static $server;
static $client;
static function headers($str) { // Parses HTTP headers into an array
$tmp = preg_split("'\r?\n'",$str);
$output = array();
$output[] = explode(' ',array_shift($tmp));
$post = ($output[0][0] == 'POST' ? true : false);
foreach($tmp as $i => $header) {
if($post && !trim($header)) {
$output['POST'] = $tmp[$i+1];
break;
}
else {
$l = explode(':',$header,2);
$output[$l[0]] = $l[0].': '.ltrim($l[1]);
}
}
return …
Run Code Online (Sandbox Code Playgroud)