Proxy
in package
Simple reverse proxy implementation for dissemination services.
Tags
Table of Contents
Properties
- $skipForwardHeaders : array<string|int, string>
- Client request headers not to be forwarded to the diss service.
- $skipResponseHeaders : array<string|int, string>
- Response headers not to be forwarded to the client.
Methods
- getForwardHeaders() : array<string, string>
- Returns all valid headers comming from the client request.
- handleResponseHeaders() : void
- Handles response headers.
- proxy() : ResponseInterface|null
- Does the job:
- sendRequest() : ResponseInterface|null
- Sends a given request
Properties
$skipForwardHeaders
Client request headers not to be forwarded to the diss service.
public
static array<string|int, string>
$skipForwardHeaders
= ['host']
$skipResponseHeaders
Response headers not to be forwarded to the client.
public
static array<string|int, string>
$skipResponseHeaders
= ['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'host']
(https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers#hbh plus host header)
Methods
getForwardHeaders()
Returns all valid headers comming from the client request.
public
static getForwardHeaders() : array<string, string>
Return values
array<string, string>handleResponseHeaders()
Handles response headers.
public
static handleResponseHeaders(Response $response) : void
Parameters
- $response : Response
proxy()
Does the job:
public
static proxy(Request $request) : ResponseInterface|null
- takes a diss service request
- adds all headers provided by the client request to it (most importantly Authentication)
- recursively issues a HEAD request to the diss service URL to resolve all redirects
- makes a final request passing client request body to the diss service and passing data returned by the diss service to the client
Parameters
- $request : Request
-
diss service request to be reverse-proxied
Tags
Return values
ResponseInterface|nullsendRequest()
Sends a given request
private
static sendRequest(Client $client, Request $request) : ResponseInterface|null
Parameters
- $client : Client
-
Guzzle HTTP client object
- $request : Request
-
request to be sent