Skip to content

Commit 84bcecd

Browse files
committed
debug develop proxy
1 parent 4e6a63b commit 84bcecd

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/Proxy.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ public function run()
4545
$dns = new DNS($this->url);
4646
$async = $this->async;
4747
$dns->lookup(function ($domain, $ip) use ($async) {
48-
$client = new Client('http://'.$domain, $async);
49-
$content = $client->send();
50-
list($headers, $content) = explode("\r\n\r\n", $content);
51-
call_user_func_array([$this, 'handle'], [$headers, $content]);
48+
$this->forward('http://'.$domain, $async);
5249
});
5350
}
5451

52+
/**
53+
* @param $url
54+
* @param string $data
55+
* @param array $headers
56+
* @return mixed
57+
*/
58+
public function forward($url, $data = '', array $headers = [])
59+
{
60+
$client = new Client($url);
61+
$client->setHeaders($headers);
62+
$content = $client->send($data);
63+
list($headers, $content) = explode("\r\n\r\n", $content);
64+
return call_user_func_array([$this, 'handle'], [$headers, $content]);
65+
}
66+
5567
/**
5668
* @param $headers
5769
* @param $response

0 commit comments

Comments
 (0)