Feature: #83736 - Extended PSR-7 requests with TYPO3 normalized server parameters
See forge#83736
Description
The PSR-7 based Server
objects created by TYPO3 now contain a TYPO3-specific attribute object for normalized
server parameters that for instance resolves variables if the instance is behind a reverse proxy. This substitutes
General
.
The object is for now available from Server
objects as attribute. The request object
is given to controllers, example:
$normalizedParams = $request->getAttribute('normalizedParams');
$requestPort = $normalizedParams->getRequestPort();
The request object is also available as a global variable in $GLOBALS
. This is a workaround for
the core which has to access the server parameters at places where $request is not available. So, while this object is
globally available during any HTTP request, it is considered bad practice to use it. The global object will vanish
later if the core code has been refactored enough to not rely on it anymore.
For now, class Normalized
is a one-to-one transition of General
, the old
arguments can be substituted with these calls:
SCRIPT_
is nowNAME ->get
Script Name () SCRIPT_
is nowFILENAME ->get
Script Filename () REQUEST_
is nowURI ->get
Request Uri () TYPO3_
is nowREV_ PROXY ->is
Behind Reverse Proxy () REMOTE_
is nowADDR ->get
Remote Address () HTTP_
is nowHOST ->get
Http Host () TYPO3_
is nowDOCUMENT_ ROOT ->get
Document Root () TYPO3_
is nowHOST_ ONLY ->get
Request Host Only () TYPO3_
is nowPORT ->get
Request Port () TYPO3_
is nowREQUEST_ HOST ->get
Request Host () TYPO3_
is nowREQUEST_ URL ->get
Request Url () TYPO3_
is nowREQUEST_ SCRIPT ->get
Request Script () TYPO3_
is nowREQUEST_ DIR ->get
Request Dir () TYPO3_
is nowSITE_ URL ->get
Site Url () TYPO3_
is nowSITE_ PATH ->get
Site Path () TYPO3_
is nowSITE_ SCRIPT ->get
Site Script () TYPO3_
is nowSSL ->is
Https ()
Some further old get
arguments directly access $request->server
and do not apply any
normalization. These have been transferred to the new class, too, but will be deprecated later if the core does not use
these anymore:
PATH_
is nowINFO ->get
, but better usePath Info () ->get
insteadScript Name () HTTP_
is nowREFERER ->get
, but better useHttp Referer () $request->get
insteadServer Params () ['HTTP_ REFERER'] HTTP_
is nowUSER_ AGENT ->get
, but better useHttp User Agent () $request->get
insteadServer Params () ['HTTP_ USER_ AGENT'] HTTP_
is nowACCEPT_ ENCODING ->get
, but better useHttp Accept Encoding () $request->get
insteadServer Params () ['HTTP_ ACCEPT_ ENCODING'] HTTP_
is nowACCEPT_ LANGUAGE ->get
, but better useHttp Accept Language () $request->get
insteadServer Params () ['HTTP_ ACCEPT_ LANGUAGE'] REMOTE_
is nowHOST ->get
, but better useRemote Host () $request->get
insteadServer Params () ['REMOTE_ HOST'] QUERY_
is nowSTRING ->get
, but better useQuery String () $request->get
insteadServer Params () ['QUERY_ STRING']
Impact
The PSR-7 request objects created by TYPO3 now contain an instance of Normalized
which can
be used instead of General
to access normalized server params.