__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Laminas\Diactoros\Response;
use Laminas\Diactoros\Exception;
use Laminas\Diactoros\Response;
use Laminas\Diactoros\Stream;
use Psr\Http\Message\StreamInterface;
use function gettype;
use function is_object;
use function is_string;
use function sprintf;
/**
* XML response.
*
* Allows creating a response by passing an XML string to the constructor; by default,
* sets a status code of 200 and sets the Content-Type header to application/xml.
*/
class XmlResponse extends Response
{
use InjectContentTypeTrait;
/**
* Create an XML response.
*
* Produces an XML response with a Content-Type of application/xml and a default
* status of 200.
*
* @param string|StreamInterface $xml String or stream for the message body.
* @param int $status Integer status code for the response; 200 by default.
* @param array $headers Array of headers to use at initialization.
* @throws Exception\InvalidArgumentException If $text is neither a string or stream.
*/
public function __construct(
$xml,
int $status = 200,
array $headers = []
) {
parent::__construct(
$this->createBody($xml),
$status,
$this->injectContentType('application/xml; charset=utf-8', $headers)
);
}
/**
* Create the message body.
*
* @param string|StreamInterface $xml
* @throws Exception\InvalidArgumentException If $xml is neither a string or stream.
*/
private function createBody($xml): StreamInterface
{
if ($xml instanceof StreamInterface) {
return $xml;
}
if (! is_string($xml)) {
throw new Exception\InvalidArgumentException(sprintf(
'Invalid content (%s) provided to %s',
is_object($xml) ? $xml::class : gettype($xml),
self::class
));
}
$body = new Stream('php://temp', 'wb+');
$body->write($xml);
$body->rewind();
return $body;
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ArraySerializer.php | File | 2.73 KB | 0664 |
|
| EmptyResponse.php | File | 885 B | 0664 |
|
| HtmlResponse.php | File | 2.01 KB | 0664 |
|
| InjectContentTypeTrait.php | File | 742 B | 0664 |
|
| JsonResponse.php | File | 4.38 KB | 0664 |
|
| RedirectResponse.php | File | 1.34 KB | 0664 |
|
| Serializer.php | File | 3.01 KB | 0664 |
|
| TextResponse.php | File | 2.02 KB | 0664 |
|
| XmlResponse.php | File | 2.04 KB | 0664 |
|