ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ?ServerRequestInterface $request = null;
39 private ?ResponseInterface $response = null;
40
41
48 public function __construct(private ResponseSenderStrategy $sender, private CookieJarFactory $cookieJarFactory, private RequestFactory $requestFactory, private ResponseFactory $responseFactory, private DurationFactory $durationFactory)
49 {
50 }
51
52 public function durations(): DurationFactory
53 {
54 return $this->durationFactory;
55 }
56
57 public function wrapper(): WrapperFactory
58 {
59 return new WrapperFactory($this->request());
60 }
61
62
66 public function cookieJar(): CookieJar
67 {
68 return $this->cookieJarFactory->fromResponse($this->response());
69 }
70
71
75 public function request(): ServerRequestInterface
76 {
77 if ($this->request === null) {
78 $this->request = $this->requestFactory->create();
79 }
80
81 return $this->request;
82 }
83
84
88 public function response(): ResponseInterface
89 {
90 if ($this->response === null) {
91 $this->response = $this->responseFactory->create();
92 }
93
94 return $this->response;
95 }
96
97
101 public function saveRequest(ServerRequestInterface $request): void
102 {
103 $this->request = $request;
104 }
105
106
110 public function saveResponse(ResponseInterface $response): void
111 {
112 $this->response = $response;
113 }
114
115
119 public function sendResponse(): void
120 {
121 // Render Cookies to the response.
122 $response = $this->response();
123 $response = $this->cookieJar()->renderIntoResponseHeader($response);
124
125 $this->sender->sendResponse($response);
126 }
127
128
129 public function close(): void
130 {
131 exit;
132 }
133}
Provides an interface to the ILIAS HTTP services.
saveResponse(ResponseInterface $response)
@inheritDoc
ServerRequestInterface $request
__construct(private ResponseSenderStrategy $sender, private CookieJarFactory $cookieJarFactory, private RequestFactory $requestFactory, private ResponseFactory $responseFactory, private DurationFactory $durationFactory)
RawHTTPServices constructor.
ResponseInterface $response
saveRequest(ServerRequestInterface $request)
@inheritDoc
exit
Interface GlobalHttpState.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...