Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Issue #60 #61

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/main/java/com/btr/proxy/selector/pac/PacProxySelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,19 @@ public List<Proxy> select(URI uri) {
* @param uri <code>URI</code> to be evaluated.
* @return <code>Proxy</code>-object list as result of the evaluation.
************************************************************************/

private List<Proxy> findProxy(URI uri) {
try {
List<Proxy> proxies = new ArrayList<Proxy>();
String parseResult = this.pacScriptParser.evaluate(uri.toString(),
String parseResult = pacScriptParser.evaluate(uri.toString(),
uri.getHost());
String[] proxyDefinitions = parseResult.split("[;]");
Logger.log(getClass(), LogLevel.TRACE, "Proxies for uri {0} -> {1}", uri, parseResult);
String[] proxyDefinitions;
if (parseResult != null) {
proxyDefinitions = parseResult.split("[;]");
}else{
Logger.log(getClass(), LogLevel.WARNING, "Pac Function returned null for uri {0}",uri);
proxyDefinitions = new String[ ]{"NULL"};
}
for (String proxyDef : proxyDefinitions) {
if (proxyDef.trim().length() > 0) {
proxies.add(buildProxyFromPacResult(proxyDef));
Expand All @@ -138,14 +144,14 @@ private List<Proxy> findProxy(URI uri) {
}

/*************************************************************************
* The proxy evaluator will return a proxy string. This method will
* take this string and build a matching <code>Proxy</code> for it.
* @param pacResult the result from the PAC parser.
* The proxy evaluator will return a proxy string. This method will
* take this string and build a matching <code>Proxy</code> for it.
* @param pacResult the result from the PAC parser.
* @return a Proxy
************************************************************************/

private Proxy buildProxyFromPacResult(String pacResult) {
if (pacResult == null || pacResult.trim().length() < 6) {
if (pacResult == null || pacResult.trim().equalsIgnoreCase("null") || pacResult.trim().length() < 6) {
return Proxy.NO_PROXY;
}
String proxyDef = pacResult.trim();
Expand Down