Package net.targetr.wtm3.net.http.proxy
Class Proxy
java.lang.Object
net.targetr.wtm3.net.http.proxy.Proxy
- Direct Known Subclasses:
CachingProxy
Opens a connection to another web server and streams response to client.
- Author:
- Dr Michael Gardiner
-
Constructor Summary
ConstructorsConstructorDescriptionProxy(HttpRequest httpReq, String target) Creates a new Proxy for relaying a request to the target web server. -
Method Summary
Modifier and TypeMethodDescriptionGets the original HTTP request.Makes the connection, sends request and returns a ProxyResponse object suitable for returning the proxied response to the client.Gets the target URL.Gets the target HTTP connection.protected ProxyResponseCreates a ProxyResponse to stream the response back.
-
Constructor Details
-
Proxy
Creates a new Proxy for relaying a request to the target web server.- Parameters:
httpReq- Request from the client to be proxied.target- The address of the target web server. Must include protocol and host.
-
-
Method Details
-
getResponse
Makes the connection, sends request and returns a ProxyResponse object suitable for returning the proxied response to the client.- 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
Creates a ProxyResponse to stream the response back.- Returns:
- A new ProxyResponse instance.
- Throws:
Exception- If an error occurs creating the response.
-
getRequest
Gets the original HTTP request.- Returns:
- The HTTP request.
-
getTarget
Gets the target URL.- Returns:
- The target URL.
-
getTargetConnection
Gets the target HTTP connection.- Returns:
- The HttpURLConnection to the target.
-