-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
34 lines (29 loc) · 1.34 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include "vendor/autoload.php";
use LeonardoBarcelos\PhpSocketRS;
try {
// $socketClient = new PhpSocketRS\ClientSocket(gethostbyname('www.google.com'), 80);
$socketClient = new PhpSocketRS\ClientSocket('127.0.0.1', 32150);
$httpRequest = new PhpSocketRS\Get();
$httpRequest->setPath('/');
$httpRequest->setHeaders([
'User-Agent' => 'PhpSocketRS/1.0',
'Accept' => '*/*',
'Host' => $socketClient->getHost()
]);
echo "--------------------------------- Requisição ---------------------------------\n";
echo $httpRequest->getSocketMessage();
echo "--------------------------------- Requisição ---------------------------------\n";
$socketClient->writeSocketMessage($httpRequest);
echo "--------------------------------- Resposta ---------------------------------\n";
echo $socketClient->getResponse();
echo "--------------------------------- Resposta ---------------------------------\n";
// $httpResponse = new PhpSocketRS\HttpResponse();
// $httpResponse->translate($socketClient->getResponse());
// echo $httpResponse->getCode() . "\n";
// echo $httpResponse->getHttpVersion() . "\n";
// echo $httpResponse->getMessage() . "\n";
// print_r($httpResponse->getHeaders());
} catch (PhpSocketRS\SocketException $e) {
echo "{$e->getCode()}: {$e->getMessage()}\n";
}