Skip to content

Commit

Permalink
A fix for Cappuccino issue 759.
Browse files Browse the repository at this point in the history
amendment.
  • Loading branch information
danielphelps authored and paulbaumgart committed Mar 18, 2011
1 parent 153c465 commit 7e20109
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion engines/rhino/bin/narwhal-rhino
Expand Up @@ -21,7 +21,15 @@ fi

CLASSPATH=$NARWHAL_ENGINE_HOME/jars/jna.jar
BOOTCLASSPATH=$NARWHAL_ENGINE_HOME/jars/js.jar
JAVA_OPTS=""

# Parse the http_proxy environment variable.
# http://cache.myproxy.com:42/ => cache.myproxy.com
http_proxy_host=`echo $http_proxy | sed 's/http:\/\/\(.*\):.*/\1/'`

# http://cache.myproxy.com:42/ => 42
http_proxy_port=`echo $http_proxy | sed 's/http:\/\/.*:\(.*\)\//\1/'`

JAVA_OPTS="-Dhttp.proxyHost=$http_proxy_host -Dhttp.proxyPort=$http_proxy_port"

if [ -n "$NARWHAL_CLASSPATH" ]; then
CLASSPATH=$NARWHAL_CLASSPATH:$CLASSPATH
Expand Down
13 changes: 12 additions & 1 deletion engines/rhino/lib/http-client-engine.js
Expand Up @@ -9,8 +9,19 @@ var IO = require("io").IO;
exports.open = function(url, mode, options) {
var connection, output, input;

function findProxy() {
selector = java.net.ProxySelector.getDefault();
proxies = selector.select(java.net.URI(url));

//This list is never empty -- at the very least, it contains
//java.net.Proxy.NO_PROXY. See java.net.ProxySelector.select()
//and java.net.Proxy.
return proxies.get(0);
}

function initConnection() {
connection = new java.net.URL(url).openConnection();
proxy = findProxy();
connection = new java.net.URL(url).openConnection(proxy);
connection.setDoInput(true);
connection.setDoOutput(false);
connection.setRequestMethod(options.method);
Expand Down

0 comments on commit 7e20109

Please sign in to comment.