Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

A fix for Cappuccino issue 759.

amendment.
  • Loading branch information...
commit 7e201097b9c85e9084261bf187871a312dc50a64 1 parent 153c465
@danielphelps danielphelps authored paulbaumgart committed
View
10 engines/rhino/bin/narwhal-rhino
@@ -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
View
13 engines/rhino/lib/http-client-engine.js
@@ -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);

0 comments on commit 7e20109

Please sign in to comment.
Something went wrong with that request. Please try again.