Class CachingProxy
java.lang.Object
net.targetr.wtm3.net.http.proxy.Proxy
net.targetr.wtm3.net.http.proxy.cache.CachingProxy
A proxy that caches responses from target servers to avoid repeated network requests.
Extends the basic Proxy functionality by checking a local cache before sending a request.
-
Constructor Summary
ConstructorsConstructorDescriptionCachingProxy(HttpRequest httpReq, String target, long maxAgeMillis) Creates a new caching proxy. -
Method Summary
Modifier and TypeMethodDescriptionMakes the connection, sends request and returns a ProxyResponse object suitable for returning the proxied response to the client.protected ProxyResponseCreates a ProxyResponse to stream the response back.Methods inherited from class net.targetr.wtm3.net.http.proxy.Proxy
getRequest, getTarget, getTargetConnection
-
Constructor Details
-
CachingProxy
Creates a new caching proxy.- Parameters:
httpReq- The incoming HTTP request.target- The target URL to proxy to.maxAgeMillis- The maximum time in milliseconds to keep the response in the cache.
-
-
Method Details
-
getResponse
Makes the connection, sends request and returns a ProxyResponse object suitable for returning the proxied response to the client.- Overrides:
getResponsein classProxy- Returns:
- Response for proxying data from the target address. Or ErrorResponse.
- Throws:
Exception- An exception occured while connecting to the target or sending request.
-
makeResponse
Description copied from class:ProxyCreates a ProxyResponse to stream the response back.- Overrides:
makeResponsein classProxy- Returns:
- A new ProxyResponse instance.
- Throws:
Exception- If an error occurs creating the response.
-