|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.w3c.www.protocol.http.proxy.ProxyDispatcher
public class ProxyDispatcher
The proxy dispatcher applies some rules to a request. The goal of that filter is to allow special pre-processing of requests based, on their target host, before sending them off the net.
The filter is configured through a rule file whose format
is described by the following BNF:
rule-file=(record)*
record=EOL|comment|rule
comment=#(^EOL)*EOL
rule=rule-lhs(SPACE)*rule-rhs
rule-lhs=(token)
|(token (.
rule-lhr=forbid|direct|redirect
|proxy|authorization|proxyauth
forbid=FORBID|forbid
direct=DIRECT|direct
redirect=(REDIRECT|proxy) url
proxy=(PROXY|proxy) url
url=any valid URL
authorization=(AUTHORIZATION|authorization
user password
proxyauth=(PROXYAUTH|proxyauth
user password url
A sample rule file looks like this:
# Some comments
edu proxy http://class.w3.org:8001/
org proxy http://class.w3.org:8001/
fr direct
www.evilsite.com redirect http://www.goodsite.com/warning.html
www.w3.org direct
138.96.24 direct
www.playboy.com forbid
default proxy http://cache.inria.fr:8080/
The algorithm used to lookup rules is the following:
In our example, a request to www.isi.edu would match the edu rule, and a request for www.w3.org would match the direct rule, for example.
Three rules are defined:
For numeric IP addresses, the most significant part is the beginning, so {A, B, C} are deducted directly. In the example { 138, 96, 24 } is mapped to direct.
If no rules are applied, then the default rule (root rule) is applied. See the example.
Field Summary | |
---|---|
protected boolean |
check_rules
|
static java.lang.String |
CHECK_RULES_LAST_MODIFIED_P
Name of the property turning that filter in debug mode. |
protected boolean |
debug
Are we in debug mode ? |
static java.lang.String |
DEBUG_P
Name of the property turning that filter in debug mode. |
protected static java.lang.String |
disabled
|
protected long |
lastParsingTime
|
protected ObservableProperties |
props
The properties we initialized ourself from. |
static java.lang.String |
RULE_P
Name of the property giving the rule file URL. |
protected RuleNode |
rules
The current set of rules to apply. |
Constructor Summary | |
---|---|
ProxyDispatcher()
Empty constructor, for dynamic instantiation. |
Method Summary | |
---|---|
boolean |
exceptionFilter(Request request,
HttpException ex)
Filter requests when an error occurs during the process. |
Reply |
ingoingFilter(Request request)
Filter requests before they are emitted. |
void |
initialize(HttpManager manager)
Initialize this filter, using the provided manager. |
protected boolean |
needsParsing()
|
Reply |
outgoingFilter(Request request,
Reply reply)
Filter requests after processing. |
protected void |
parseRules()
Parse the default set of rules. |
protected void |
parseRules(java.io.InputStream in)
Parse the given input stream as a rule file. |
boolean |
propertyChanged(java.lang.String name)
PropertyMonitoring implementation - Commit property changes. |
void |
sync()
We don't maintain cached infos. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String RULE_P
public static final java.lang.String DEBUG_P
public static final java.lang.String CHECK_RULES_LAST_MODIFIED_P
protected ObservableProperties props
protected RuleNode rules
protected boolean debug
protected boolean check_rules
protected static final java.lang.String disabled
protected long lastParsingTime
Constructor Detail |
---|
public ProxyDispatcher()
Method Detail |
---|
protected void parseRules(java.io.InputStream in) throws java.io.IOException, RuleParserException
in
- The input stream to parse.
java.io.IOException
- if an IO error occurs.
RuleParserException
- if parsing failed.protected void parseRules()
IOf the rules cannot be parsed, the filter emits an error message to standard error, and turn itself into transparent mode.
protected boolean needsParsing()
public Reply ingoingFilter(Request request)
ingoingFilter
in interface RequestFilter
request
- The request to filter.
public boolean exceptionFilter(Request request, HttpException ex)
exceptionFilter
in interface RequestFilter
reques
- The request to filter.reply
- It's associated reply.
public Reply outgoingFilter(Request request, Reply reply)
outgoingFilter
in interface RequestFilter
reques
- The request to filter.reply
- It's associated reply.
public boolean propertyChanged(java.lang.String name)
propertyChanged
in interface PropertyMonitoring
name
- The name of the property that has changed.
public void initialize(HttpManager manager)
PropRequestFilter
setFilter
method.
initialize
in interface PropRequestFilter
manager
- The HttpManager initializing the filter.public void sync()
sync
in interface RequestFilter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |