public class RequestForTargetConsumer extends AbsClientRequestConsumer
AbsClientRequestConsumer
to consume a client request that will be forwarded to a remote Target.
This class examines the incoming request from the client to see if it is mappable to a remote Target.
If no viable mapping can be found for the request, this class instructs it's ResponseProducer
to return a 404 NOT_FOUND resoponse the the client.buffer, context, Logger, producer
Constructor and Description |
---|
RequestForTargetConsumer(org.apache.http.protocol.HttpContext context,
org.apache.http.nio.protocol.HttpAsyncRequester executor,
org.apache.http.impl.nio.pool.BasicNIOConnPool connPool,
Map<String,TargetDescriptor> patternTargetMapping,
ConcurrentMap<String,org.apache.http.HttpHost> dynamicHostMap,
org.apache.http.HttpRequest targetRequest,
BufferIOController requestBuffer,
BufferIOController responseBuffer,
ScriptObjectMirror endpoint)
Primary constructor
|
Modifier and Type | Method and Description |
---|---|
void |
requestReceived(org.apache.http.HttpRequest clientRequest)
Find a remote target that matches the requested uri, *or* return a 404 NOT_FOUND response if a mapping is not present.
|
static String |
UriToTargetKey(String remoteTargetUri,
String[] scheme,
String[] host,
int[] port,
String[] path,
int[] stripPrefixCount) |
static String |
UriToTargetKey(URI remoteTargetUri,
String[] scheme,
String[] host,
int[] port,
String[] path,
int[] stripPrefixCount)
Break out a
URI into it's component parts, and re-assemble them into a lowercase key representing the target. |
close, consumeContent, failed, getException, getResult, isDone, requestCompleted
public RequestForTargetConsumer(org.apache.http.protocol.HttpContext context, org.apache.http.nio.protocol.HttpAsyncRequester executor, org.apache.http.impl.nio.pool.BasicNIOConnPool connPool, Map<String,TargetDescriptor> patternTargetMapping, ConcurrentMap<String,org.apache.http.HttpHost> dynamicHostMap, org.apache.http.HttpRequest targetRequest, BufferIOController requestBuffer, BufferIOController responseBuffer, ScriptObjectMirror endpoint)
context
- Context of this request / response transactionexecutor
- HttpAsyncRequester
which will perform the actual request to the remote Target and recieve it's response.connPool
- The client connection pool that will be used by the executor
patternTargetMapping
- The mapping of relative uri paths to configured Targets.dynamicHostMap
- If non-null, this is a request modified by a JavaScript endpoint, *and* we are configured to allow the endpoint's to proxy to remote Target's not specified in the configuration file.requestBuffer
- Buffer used to read in the request content from a client (if any) which will then be flipped and sent out to the Target by the TargetRequestProducer
responseBuffer
- Buffer used to read in the response content from the remote Target (if any) which will then be flipped and sent back to the client by the TargetResponseConsumer
endpoint
- If non-null, the script endpoint which has interjected itself into this transaction.public void requestReceived(org.apache.http.HttpRequest clientRequest)
public static String UriToTargetKey(String remoteTargetUri, String[] scheme, String[] host, int[] port, String[] path, int[] stripPrefixCount)
public static String UriToTargetKey(URI remoteTargetUri, String[] scheme, String[] host, int[] port, String[] path, int[] stripPrefixCount)
URI
into it's component parts, and re-assemble them into a lowercase key representing the target.remoteTargetUri
- The inputscheme
- "pass-by-reference" which if non-null will be populated with: https or http (if not explicitly https)host
- "pass-by-reference" which if non-null will be populated with: The name of the Target server.port
- "pass-by-reference" which if non-null will be populated with: The port the Target server is listening on (if not specified will be 80 for http and 443 for https).path
- "pass-by-reference" which if non-null will be populated with: The Path portion of the provided uri.stripPrefixCount
- "pass-by-reference" which if non-null will be populated with: This is actually an Integer.parse of the anchor portion of the uri which is used as a means to specify how much of the requesting uri should be stripped off before appending it to the host:port/path of the Target.Copyright © 2015–2024 Frank Stock. All rights reserved.