ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Repository\HTTP\HTTPUtil Class Reference
+ Collaboration diagram for ILIAS\Repository\HTTP\HTTPUtil:

Public Member Functions

 __construct (HTTP\Services $http)
 
 sendString (string $output)
 
 sendJson (\stdClass $data)
 
 deliverString (string $data, string $filename, string $mime="application/octet-stream")
 
 deliverStream (FileStream $stream, string $filename, string $mime="application/octet-stream")
 

Protected Attributes

HTTP Services $http
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 31 of file class.HTTPUtil.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Repository\HTTP\HTTPUtil::__construct ( HTTP\Services  $http)

Definition at line 35 of file class.HTTPUtil.php.

References ILIAS\Repository\HTTP\HTTPUtil\$http, and ILIAS\Repository\http().

+ Here is the call graph for this function:

Member Function Documentation

◆ deliverStream()

ILIAS\Repository\HTTP\HTTPUtil::deliverStream ( FileStream  $stream,
string  $filename,
string  $mime = "application/octet-stream" 
)

Definition at line 81 of file class.HTTPUtil.php.

85 : void {
86 $delivery = new Delivery(
88 $this->http
89 );
90 $delivery->setMimeType($mime);
91 $delivery->setSendMimeType(true);
92 $delivery->setDisposition(Delivery::DISP_ATTACHMENT);
93 $delivery->setDownloadFileName($filename);
94 $delivery->setConvertFileNameToAsci(true);
95 $repsonse = $this->http->response()->withBody($stream);
96 $this->http->saveResponse($repsonse);
97 $delivery->deliver();
98 }
$filename
Definition: buildRTE.php:78

◆ deliverString()

ILIAS\Repository\HTTP\HTTPUtil::deliverString ( string  $data,
string  $filename,
string  $mime = "application/octet-stream" 
)

Definition at line 62 of file class.HTTPUtil.php.

66 : void {
67 $delivery = new Delivery(
69 $this->http
70 );
71 $delivery->setMimeType($mime);
72 $delivery->setSendMimeType(true);
73 $delivery->setDisposition(Delivery::DISP_ATTACHMENT);
74 $delivery->setDownloadFileName($filename);
75 $delivery->setConvertFileNameToAsci(true);
76 $repsonse = $this->http->response()->withBody(Streams::ofString($data));
77 $this->http->saveResponse($repsonse);
78 $delivery->deliver();
79 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41

◆ sendJson()

ILIAS\Repository\HTTP\HTTPUtil::sendJson ( \stdClass  $data)

Definition at line 49 of file class.HTTPUtil.php.

49 : void
50 {
52 $string = json_encode($data);
54 $http->saveResponse($http
55 ->response()
56 ->withAddedHeader('Content-Type', 'application/json')
57 ->withBody($stream));
58 $http->sendResponse();
59 $http->close();
60 }

References $data, ILIAS\Repository\HTTP\HTTPUtil\$http, and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ sendString()

ILIAS\Repository\HTTP\HTTPUtil::sendString ( string  $output)

Definition at line 40 of file class.HTTPUtil.php.

40 : void
41 {
42 $this->http->saveResponse($this->http->response()->withBody(
43 Streams::ofString($output)
44 ));
45 $this->http->sendResponse();
46 $this->http->close();
47 }

References ILIAS\Repository\http(), and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

Field Documentation

◆ $http

HTTP Services ILIAS\Repository\HTTP\HTTPUtil::$http
protected

The documentation for this class was generated from the following file: