Initial commit

This commit is contained in:
2017-02-16 16:29:55 +01:00
commit c3531ce5fa
21 changed files with 1383 additions and 0 deletions

45
src/HTTPU/Response.php Normal file
View File

@ -0,0 +1,45 @@
<?php
namespace NoccyLabs\UPnP\HTTPU;
class Response
{
protected $headers = [];
protected $ip;
public function __construct(array $headers, $ip)
{
$this->headers = $headers;
$this->ip = $ip;
}
public static function createFromString($string, $ip)
{
$data = explode("\r\n", trim($string));
$status = array_shift($data);
$headers = [];
foreach ($data as $line) {
list ($header, $value) = array_map("trim", explode(":",$line,2));
$headers[strtolower($header)] = $value;
}
// Test for search responses using the ST header
if (array_key_exists('st', $headers)) {
return new MSearchResponse($headers, $ip);
}
}
public function getIp()
{
return $this->ip;
}
public function getLocation()
{
return $this->headers['location'];
}
}