|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.props.Props
com.cometway.ak.Agent
com.cometway.ak.ServiceAgent
com.cometway.httpd.WebServerExtension
com.cometway.httpd.HTTPProxyAgent
public class HTTPProxyAgent
This agent handles proxies to other web servers. A file needs to be provided which lists the full URLs or URIs to proxy and where they should be proxied to. The proxy config file consists of name/value pairs separated by newlines. Lines beginning with the # character are ignored as comments. The value of each name/value pair must be a full URL. The following are some valid name/value pairs that can be used in the config file: /directory=http://www.domain.com/directory.agent /dir/page.html=http://www.domain2.com/index.html http://www.domain.com/index.html=http://www.domain2.com/index.html http://domain.com/index.html=http://www.domain2.com/index.html http://www.anotherdomain.com/=http://www.domain2.com:8080/ Both the name and the value of each name/value pair is assumed to be literal, so they will cnly match the exact path/host of the http request. Loose proxies are ones where the entire path is passed to the proxied host. Loose proxies are denoted as "*=": http://www.domain.com/search/*=http://www.google.com/ In this example, http://www.domain.com/search/ will be proxied to http://www.google.com/ and http://www.domain.com/search/search?q=help will be proxied to http://www.google.com/search?q=help Essentially, everything after the name in the name/value pair, will be passed onto what the value is.
| Field Summary | |
|---|---|
protected java.util.Hashtable |
socketHash
|
protected boolean |
stopRunning
|
protected java.lang.Object |
syncObject
|
protected java.lang.Thread |
thread
|
| Fields inherited from class com.cometway.ak.Agent |
|---|
agent_id, agentController, CREATING_STATE, debugReporter, DESTROYED_STATE, DESTROYING_STATE, errorReporter, FAILED_STATE, printlnReporter, props, RUNNING_STATE, STARTING_STATE, STOPPED_STATE, STOPPING_STATE, warningReporter |
| Constructor Summary | |
|---|---|
HTTPProxyAgent()
|
|
| Method Summary | |
|---|---|
protected java.net.Socket |
getProxySocket(java.lang.String hostname,
int port,
java.lang.String request)
This method gets or creates a Socket to a proxy host and sends the HTTP request. |
boolean |
handleRequest(HTTPAgentRequest request)
Handles a request and routes through appropriate proxy. |
void |
initProps()
Initializes this agent's properties by providing default values for each of the following missing properties: "service_name" is used to register this agent with the Service Manager (default: http_proxy.agent), "proxy_file" contains a list of the available proxies (default: ./http.proxy), "check_interval" specifies the time to wait before checking a proxy's status (default: 300000), "initial_wait_time" specifies the time to wait initially before checking a proxy (default: 60000). |
boolean |
isProxied(java.lang.String path,
java.lang.String host)
Checks to see if a path is Proxied. |
void |
readProxyFile()
Reads in Proxy File's information into a database of proxies. |
void |
returnProxySocket(java.lang.String hostname,
int port,
java.net.Socket s)
Returns a keep-alive connection to the SocketHash |
void |
run()
Runs and synchronizes object, then checks proxies. |
void |
start()
Registers service with Object Manager, reads in Proxy File, and starts a new thread for this object. |
void |
stop()
Unregisters this instance with the service manager using the service_name property. |
| Methods inherited from class com.cometway.ak.Agent |
|---|
currentStateEquals, debug, destroy, error, error, getAgentController, getDateTimeStr, getProps, getServiceImpl, getStateMachineModel, println, register, registerService, setAgentController, setProps, toString, unregister, unregisterService, warning, warning |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected boolean stopRunning
protected java.lang.Thread thread
protected java.lang.Object syncObject
protected java.util.Hashtable socketHash
| Constructor Detail |
|---|
public HTTPProxyAgent()
| Method Detail |
|---|
public void initProps()
initProps in interface AgentInterfaceinitProps in class Agentpublic void start()
start in interface AgentInterfacestart in class WebServerExtensionpublic void stop()
ServiceAgent
stop in interface AgentInterfacestop in class ServiceAgentpublic void readProxyFile()
public boolean handleRequest(HTTPAgentRequest request)
handleRequest in class WebServerExtension
protected java.net.Socket getProxySocket(java.lang.String hostname,
int port,
java.lang.String request)
public void returnProxySocket(java.lang.String hostname,
int port,
java.net.Socket s)
public boolean isProxied(java.lang.String path,
java.lang.String host)
public void run()
run in interface java.lang.Runnable
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||