ILIAS  release_8 Revision v8.24
RawHTTPServices.php
Go to the documentation of this file.
1<?php
2
19namespace ILIAS\HTTP;
20
28use Psr\Http\Message\ResponseInterface;
29use Psr\Http\Message\ServerRequestInterface;
30
37{
38 private \ILIAS\HTTP\Response\Sender\ResponseSenderStrategy $sender;
39 private \ILIAS\HTTP\Cookies\CookieJarFactory $cookieJarFactory;
40 private \ILIAS\HTTP\Request\RequestFactory $requestFactory;
41 private \ILIAS\HTTP\Response\ResponseFactory $responseFactory;
42 private \ILIAS\HTTP\Duration\DurationFactory $durationFactory;
43 private ?\Psr\Http\Message\ServerRequestInterface $request = null;
44 private ?\Psr\Http\Message\ResponseInterface $response = null;
45
46
53 public function __construct(
54 ResponseSenderStrategy $senderStrategy,
59 ) {
60 $this->sender = $senderStrategy;
61 $this->cookieJarFactory = $cookieJarFactory;
62 $this->requestFactory = $requestFactory;
63 $this->responseFactory = $responseFactory;
64 $this->durationFactory = $durationFactory;
65 }
66
67 public function durations(): DurationFactory
68 {
70 }
71
72 public function wrapper(): WrapperFactory
73 {
74 return new WrapperFactory($this->request());
75 }
76
77
81 public function cookieJar(): CookieJar
82 {
83 return $this->cookieJarFactory->fromResponse($this->response());
84 }
85
86
90 public function request(): \Psr\Http\Message\RequestInterface
91 {
92 if ($this->request === null) {
93 $this->request = $this->requestFactory->create();
94 }
95
96 return $this->request;
97 }
98
99
103 public function response(): ResponseInterface
104 {
105 if ($this->response === null) {
106 $this->response = $this->responseFactory->create();
107 }
108
109 return $this->response;
110 }
111
112
116 public function saveRequest(ServerRequestInterface $request): void
117 {
118 $this->request = $request;
119 }
120
121
125 public function saveResponse(ResponseInterface $response): void
126 {
127 $this->response = $response;
128 }
129
130
134 public function sendResponse(): void
135 {
136 // Render Cookies to the response.
137 $response = $this->response();
138 $response = $this->cookieJar()->renderIntoResponseHeader($response);
139
140 $this->sender->sendResponse($response);
141 }
142
143
144 public function close(): void
145 {
146 exit;
147 }
148}
Provides an interface to the ILIAS HTTP services.
saveResponse(ResponseInterface $response)
@inheritDoc
Psr Http Message ResponseInterface $response
ILIAS HTTP Response Sender ResponseSenderStrategy $sender
ILIAS HTTP Response ResponseFactory $responseFactory
Psr Http Message ServerRequestInterface $request
__construct(ResponseSenderStrategy $senderStrategy, CookieJarFactory $cookieJarFactory, RequestFactory $requestFactory, ResponseFactory $responseFactory, DurationFactory $durationFactory)
RawHTTPServices constructor.
saveRequest(ServerRequestInterface $request)
@inheritDoc
ILIAS HTTP Cookies CookieJarFactory $cookieJarFactory
ILIAS HTTP Request RequestFactory $requestFactory
ILIAS HTTP Duration DurationFactory $durationFactory
Interface GlobalHttpState.
exit
Definition: login.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...