Class FastCGIProxyHandler
- All Implemented Interfaces:
Handler, Request.Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable
Specific implementation of ProxyHandler.Reverse for FastCGI.
This handler accepts an HTTP request and transforms it into a FastCGI request that is sent to the FastCGI server, and viceversa for the response.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class ProxyHandler
ProxyHandler.Forward, ProxyHandler.ProxyRequestContent, ProxyHandler.ProxyResponseListener, ProxyHandler.ReverseNested classes/interfaces inherited from class Handler.Abstract
Handler.Abstract.NonBlockingNested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainerNested classes/interfaces inherited from interface Handler
Handler.Abstract, Handler.AbstractContainer, Handler.Collection, Handler.Container, Handler.Sequence, Handler.Singleton, Handler.WrapperNested classes/interfaces inherited from interface Invocable
Invocable.Callable, Invocable.InvocationType, Invocable.ReadyTask, Invocable.TaskNested classes/interfaces inherited from interface LifeCycle
LifeCycle.ListenerNested classes/interfaces inherited from interface Request.Handler
Request.Handler.AbortException -
Field Summary
Fields inherited from interface Invocable
__nonBlocking, NOOP -
Constructor Summary
ConstructorsConstructorDescriptionFastCGIProxyHandler(String uriPattern, String uriReplacement, String scriptRoot) Creates a new instance that rewrites theHttpURIwith the given pattern and replacement strings, usingString.replaceAll(String, String).FastCGIProxyHandler(Function<Request, HttpURI> httpURIRewriter, String scriptRoot) Creates a new instance with the givenHttpURIrewriter function. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcustomizeFastCGIHeaders(Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders) protected voiddoStart()Starts the managed lifecycle beans in the order they were added.Get the root directory path of the FastCGI files.booleanprotected HttpClientCreates a newHttpClientinstance, by default with a thread pool namedproxy-clientand with thedynamic transportconfigured only with HTTP/1.1.protected voidsendProxyToServerRequest(Request clientToProxyRequest, Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) voidsetFastCGIEnvNames(Set<String> fcgiEnvNames) Sets the names of environment variables that will forwarded, along with their value retrieved viaSystem.getenv(String), in the FastCGI request to the FastCGI server.voidsetFastCGISecure(boolean fcgiSecure) Sets whether to forward theHTTPSFastCGI parameter in the FastCGI request to the FastCGI server.voidsetOriginalPathAttribute(String originalPathAttribute) Sets the client-to-proxy request attribute name to use to retrieve the original request path.voidsetOriginalQueryAttribute(String originalQueryAttribute) Sets the client-to-proxy request attribute name to use to retrieve the original request query.voidsetScriptPattern(Pattern scriptPattern) Sets a regular expression with at least 1 and at most 2 groups that specify respectively:voidsetUnixDomainPath(Path unixDomainPath) Sets the Unix-Domain path the FastCGI server listens to.Methods inherited from class ProxyHandler.Reverse
getHttpURIRewriter, rewriteHttpURIMethods inherited from class ProxyHandler
addForwardedHeader, addProxyHeaders, addViaHeader, configureHttpClient, copyRequestHeaders, filterServerToProxyResponseField, getHttpClient, getProxyToServerHost, getViaHost, handle, newProxyToServerRequest, newProxyToServerRequestContent, newServerToProxyResponseListener, onProxyToClientResponseComplete, onProxyToClientResponseFailure, onServerToProxyResponse100Continue, onServerToProxyResponse102Processing, onServerToProxyResponse103EarlyHints, onServerToProxyResponseFailure, requestId, setHttpClient, setProxyToServerHost, setViaHostMethods inherited from class Handler.Abstract
destroy, doStop, getInvocationType, getServer, setServerMethods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpableMethods inherited from interface LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
FastCGIProxyHandler
Creates a new instance that rewrites the
HttpURIwith the given pattern and replacement strings, usingString.replaceAll(String, String).- Parameters:
uriPattern- the regex pattern to use to match the incoming URIuriReplacement- the replacement string to use to rewrite the incoming URIscriptRoot- the root directory path of the FastCGI files- See Also:
-
FastCGIProxyHandler
Creates a new instance with the given
HttpURIrewriter function.The
HttpURIrewriter function should return the URI of the FastCGI server.The
scriptRootpath must be set to the directory where the application that must be served via FastCGI is installed and corresponds to the FastCGIDOCUMENT_ROOTparameter.- Parameters:
httpURIRewriter- a function that returns the URI of the FastCGI serverscriptRoot- the root directory path of the FastCGI files
-
-
Method Details
-
getScriptRoot
Get the root directory path of the FastCGI files.- Returns:
- the root directory path of the FastCGI files
-
getScriptPattern
- Returns:
- the regular expression that extracts the
SCRIPT_NAMEand thePATH_INFOFastCGI parameters
-
setScriptPattern
Sets a regular expression with at least 1 and at most 2 groups that specify respectively:
- the FastCGI
SCRIPT_NAMEparameter - the FastCGI
PATH_INFOparameter
- Parameters:
scriptPattern- the regular expression that extracts theSCRIPT_NAMEand thePATH_INFOFastCGI parameters
- the FastCGI
-
getOriginalPathAttribute
- Returns:
- the attribute name of the original client-to-proxy request path
-
setOriginalPathAttribute
Sets the client-to-proxy request attribute name to use to retrieve the original request path.
For example, the request URI may be rewritten by a previous handler that might save the original request path in a request attribute.
- Parameters:
originalPathAttribute- the attribute name of the original client-to-proxy request path
-
getOriginalQueryAttribute
- Returns:
- the attribute name of the original client-to-proxy request query
-
setOriginalQueryAttribute
Sets the client-to-proxy request attribute name to use to retrieve the original request query.
For example, the request URI may be rewritten by a previous handler that might save the original request query in a request attribute.
- Parameters:
originalQueryAttribute- the attribute name of the original client-to-proxy request query
-
isFastCGISecure
public boolean isFastCGISecure()- Returns:
- whether to forward the
HTTPSFastCGI parameter in the FastCGI request
-
setFastCGISecure
public void setFastCGISecure(boolean fcgiSecure) Sets whether to forward the
HTTPSFastCGI parameter in the FastCGI request to the FastCGI server.- Parameters:
fcgiSecure- whether to forward theHTTPSFastCGI parameter in the FastCGI request
-
getFastCGIEnvNames
-
setFastCGIEnvNames
Sets the names of environment variables that will forwarded, along with their value retrieved via
System.getenv(String), in the FastCGI request to the FastCGI server.- Parameters:
fcgiEnvNames- the names of the environment variables forwarded in the FastCGI request- See Also:
-
getUnixDomainPath
- Returns:
- the Unix-Domain path the FastCGI server listens to,
or
nullif the FastCGI server listens over network
-
setUnixDomainPath
Sets the Unix-Domain path the FastCGI server listens to.
If the FastCGI server listens over the network (not over a Unix-Domain path), then the FastCGI server host and port must be specified by the
HttpURIrewrite function passed to the constructor.- Parameters:
unixDomainPath- the Unix-Domain path the FastCGI server listens to
-
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
doStartin classProxyHandler- Throws:
Exception- If there was a problem starting. Will cause a transition to FAILED state
-
newHttpClient
Description copied from class:ProxyHandlerCreates a new
HttpClientinstance, by default with a thread pool namedproxy-clientand with thedynamic transportconfigured only with HTTP/1.1.- Overrides:
newHttpClientin classProxyHandler- Returns:
- a new
HttpClientinstance
-
sendProxyToServerRequest
protected void sendProxyToServerRequest(Request clientToProxyRequest, Request proxyToServerRequest, Response proxyToClientResponse, Callback proxyToClientCallback) - Overrides:
sendProxyToServerRequestin classProxyHandler
-
customizeFastCGIHeaders
protected void customizeFastCGIHeaders(Request proxyToServerRequest, HttpFields.Mutable fastCGIHeaders)
-