@@ -42,43 +42,80 @@ namespace Corpus\HttpMessageUtils;
4242
4343class ProxyAwareSchemer {
4444 public const HTTPS_EXPECTED_SERVER_VALUES = ['HTTP_X_FORWARDED_PROTOCOL' => 'https', 'HTTP_X_FORWARDED_PROTO' => 'https', 'HTTP_X_FORWARDED_SSL' => 'on', 'HTTP_FRONT_END_HTTPS' => 'on', 'HTTP_X_URL_SCHEME' => 'https', 'HTTPS' => 'on'];
45+ public const PORT_EXPECTED_SERVER_KEYS = ['HTTP_X_FORWARDED_PORT'];
46+ /** Value for `default port` arguments to remove the port from the URI */
47+ public const REMOVE_PORT = -65536;
4548}
4649```
4750
4851#### Method: ProxyAwareSchemer->__ construct
4952
5053``` php
51- function __construct([ ?array $proxyServerValues = null [, ?array $server = null]])
54+ function __construct([ ?array $server = null [, ?array $proxyServerHttpsKeyValues = null [, ?array $proxyServerPortKeys = null] ]])
5255```
5356
5457##### Parameters:
5558
56- - *** array*** | *** null*** ` $proxyServerValues ` - Map of $_ SERVER keys to their expected https-positive value. Defaults to
57- self::HTTPS_EXPECTED_SERVER_VALUES
5859- *** array*** | *** null*** ` $server ` - Server array to inspect. Defaults to $_ SERVER.
60+ - *** array*** | *** null*** ` $proxyServerHttpsKeyValues ` - Map of $_ SERVER keys to their expected https-positive value.
61+ Defaults to ProxyAwareSchemer::HTTPS_EXPECTED_SERVER_VALUES
62+ - *** string[ ] *** | *** null*** ` $ ` - Array of $_ SERVER keys to check for a forwarded port value.
5963
6064---
6165
6266#### Method: ProxyAwareSchemer->withUriWithDetectedScheme
6367
6468``` php
65- function withUriWithDetectedScheme(\Psr\Http\Message\ServerRequestInterface $serverRequest) : \Psr\Http\Message\ServerRequestInterface
69+ function withUriWithDetectedScheme(\Psr\Http\Message\ServerRequestInterface $serverRequest [, bool $detectPort = true [, ?int $defaultOnHttps = self::REMOVE_PORT]] ) : \Psr\Http\Message\ServerRequestInterface
6670```
6771
6872Given a \Psr\Http\Message\ServerRequestInterface returns a new instance of ServerRequestInterface with a new Uri
6973having the scheme adjusted to match the detected external scheme as defined by the proxies headers.
7074
75+ ##### Parameters:
76+
77+ - *** bool*** ` $detectPort ` - Enable / Disable proxy port sniffing.
78+ - *** int*** | *** null*** ` $defaultOnHttps ` - Default port to use if sniffing fails but HTTPS proxy is detected.
79+ Defaults to ProxyAwareSchemer::REMOVE_PORT which removes the port information
80+ from the URI.
81+ Passing null will leave port as-is.
82+
7183---
7284
7385#### Method: ProxyAwareSchemer->withDetectedScheme
7486
7587``` php
76- function withDetectedScheme(\Psr\Http\Message\UriInterface $uri) : \Psr\Http\Message\UriInterface
88+ function withDetectedScheme(\Psr\Http\Message\UriInterface $uri [, bool $detectPort = true [, ?int $defaultOnHttps = self::REMOVE_PORT]] ) : \Psr\Http\Message\UriInterface
7789```
7890
79- Given a \Psr\Http\Message\UriInterface returns a new instance of UriInterface having the scheme adjusted to match
91+ Given a \Psr\Http\Message\UriInterface returns a instance of UriInterface having the scheme adjusted to match
8092the detected external scheme as defined by the proxies headers.
8193
94+ ##### Parameters:
95+
96+ - *** bool*** ` $detectPort ` - Enable / Disable proxy port sniffing.
97+ - *** int*** | *** null*** ` $defaultOnHttps ` - Default port to use if sniffing fails but HTTPS proxy is detected.
98+ Defaults to ProxyAwareSchemer::REMOVE_PORT which removes the port information
99+ from the URI.
100+ Passing null will leave port as-is.
101+
102+ ---
103+
104+ #### Method: ProxyAwareSchemer->withDetectedPort
105+
106+ ``` php
107+ function withDetectedPort(\Psr\Http\Message\UriInterface $uri [, ?int $default = null]) : \Psr\Http\Message\UriInterface
108+ ```
109+
110+ Given a \Psr\Http\Message\UriInterface returns a instance of UriInterface having the port adjusted to match
111+ the detected external scheme as defined by the proxies headers.
112+
113+ ##### Parameters:
114+
115+ - *** int*** | *** null*** ` $default ` - Defines a default fallback port.
116+ Passing ProxyAwareSchemer::REMOVE_PORT will default to removing the port information.
117+ Defaults to null - null leaves port as-is.
118+
82119### Class: \Corpus\HttpMessageUtils\ResponseSender
83120
84121Utility to actualize a PSR7 ResponseInterface
0 commit comments