ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\HTTP\Request\RequestFactoryImpl Class Reference
+ Inheritance diagram for ILIAS\HTTP\Request\RequestFactoryImpl:
+ Collaboration diagram for ILIAS\HTTP\Request\RequestFactoryImpl:

Public Member Functions

 __construct (private ?string $forwarded_header=null, private ?string $forwarded_proto=null)
 
 create ()
 Creates a new ServerRequest object with the help of the underlying library. More...
 
 create ()
 Creates a new ServerRequest object with the help of the underlying library. More...
 

Private Attributes

const DEFAULT_FORWARDED_HEADER = 'X-Forwarded-Proto'
 
const DEFAULT_FORWARDED_PROTO = 'https'
 

Detailed Description

Definition at line 38 of file RequestFactoryImpl.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\HTTP\Request\RequestFactoryImpl::__construct ( private ?string  $forwarded_header = null,
private ?string  $forwarded_proto = null 
)

Definition at line 49 of file RequestFactoryImpl.php.

52 {
53 }

Member Function Documentation

◆ create()

ILIAS\HTTP\Request\RequestFactoryImpl::create ( )

Creates a new ServerRequest object with the help of the underlying library.

Implements ILIAS\HTTP\Request\RequestFactory.

Definition at line 55 of file RequestFactoryImpl.php.

55 : ServerRequestInterface
56 {
57 $server_request = ServerRequest::fromGlobals();
58
59 if ($this->forwarded_header !== null && $this->forwarded_proto !== null) {
60 if (in_array(
61 $this->forwarded_proto,
62 $server_request->getHeader($this->forwarded_header),
63 true
64 )) {
65 return $server_request->withUri($server_request->getUri()->withScheme($this->forwarded_proto));
66 }
67
68 // alternative if ini settings are used which look like X_FORWARDED_PROTO
69 $header_names = array_keys($server_request->getHeaders());
70 foreach ($header_names as $header_name) {
71 if (str_replace("-", "_", strtoupper($header_name)) !== $this->forwarded_header) {
72 continue;
73 }
74 if (!in_array($this->forwarded_proto, $server_request->getHeader($header_name), true)) {
75 continue;
76 }
77 return $server_request->withUri($server_request->getUri()->withScheme($this->forwarded_proto));
78 }
79 }
80
81 return $server_request;
82 }

Field Documentation

◆ DEFAULT_FORWARDED_HEADER

const ILIAS\HTTP\Request\RequestFactoryImpl::DEFAULT_FORWARDED_HEADER = 'X-Forwarded-Proto'
private

Definition at line 43 of file RequestFactoryImpl.php.

◆ DEFAULT_FORWARDED_PROTO

const ILIAS\HTTP\Request\RequestFactoryImpl::DEFAULT_FORWARDED_PROTO = 'https'
private

Definition at line 47 of file RequestFactoryImpl.php.


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