php-upnp/src/HTTPU/Request.php

54 lines
1.0 KiB
PHP

<?php
namespace NoccyLabs\UPnP\HTTPU;
class Request
{
protected $request;
protected $host;
protected $port;
public function __construct($request_line, $host, $port)
{
$this->request = $request_line;
$this->host = $host;
$this->port = $port;
}
public function getAddress()
{
return $this->host;
}
public function getPort()
{
return $this->port;
}
public function getBuffer()
{
$this->headers['Host'] = sprintf("%s:%d", $this->host, $this->port);
$buffer = $this->request . "\r\n";
foreach ($this->headers as $key=>$value) {
$buffer.= sprintf("%s: %s\r\n", $key, $value);
}
$buffer.= "\r\n";
return $buffer;
}
public function setUserAgent($os, $os_version, $product, $product_version)
{
$this->headers['User-Agent'] = sprintf("%s/%s UPnP/1.1 %s/%s",
$os, $os_version,
$product, $product_version
);
}
}