ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\StaticURL\Request\Request\RequestFactoryImpl Class Reference
+ Inheritance diagram for ILIAS\StaticURL\Request\Request\RequestFactoryImpl:
+ Collaboration diagram for ILIAS\StaticURL\Request\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...
 

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\StaticURL\Request\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\StaticURL\Request\Request\RequestFactoryImpl::create ( )

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

Implements ILIAS\StaticURL\Request\Request\RequestFactory.

Definition at line 55 of file RequestFactoryImpl.php.

References null.

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

Field Documentation

◆ DEFAULT_FORWARDED_HEADER

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

Definition at line 43 of file RequestFactoryImpl.php.

◆ DEFAULT_FORWARDED_PROTO

const ILIAS\StaticURL\Request\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: