Skip to content

Commit

Permalink
HttpRequest proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
richcollins committed Dec 18, 2010
1 parent 1c0155b commit 1fccc84
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
12 changes: 12 additions & 0 deletions lib/Crux/Object.js
Expand Up @@ -16,6 +16,18 @@ Object_slotNames = function(source)
return names;
}

Object_slotValues = function(source)
{
var values = [];

for(var name in source)
{
values.push(source[name]);
}

return values;
}

Object_popFirstKey = function(source)
{
// warning! This is SLOW.
Expand Down
9 changes: 6 additions & 3 deletions lib/NodeCrux/HttpRequest.js
Expand Up @@ -12,7 +12,9 @@ HttpRequest = Delegator.clone().setProtoType("HttpRequest").newSlots({
debug: false,
didComplete: false,
maxConcurrency: 0,
timeout: 0 //seconds
timeout: 0, //seconds
proxyHost: null,
proxyPort: null
}).setSlots({
init: function()
{
Expand Down Expand Up @@ -165,7 +167,8 @@ HttpRequest = Delegator.clone().setProtoType("HttpRequest").newSlots({

var self = this;

var port = this.url().port() || 80;
var clientPort = this.proxyPort() || this.url().port() || 80;
var clientHost = this.proxyHost() || this.url().host();
this.generateHeaders();

if(this.timeout())
Expand All @@ -175,7 +178,7 @@ HttpRequest = Delegator.clone().setProtoType("HttpRequest").newSlots({
}, this.timeout() * 1000);
}

var client = http.createClient(port, this.url().host());
var client = http.createClient(clientPort, clientHost);
this._nativeClient = client;
//this.patchEmitter(client, "client");
client.on("error", function(e)
Expand Down
2 changes: 2 additions & 0 deletions lib/Vertex/PDB.js
Expand Up @@ -264,6 +264,7 @@ PDB = Proto.clone().newSlots({
}

this.rememberKeyForUndo(k);
//writeln("put: ", k, " => ", v);
this._tc.put(k, v);
return this;
},
Expand All @@ -272,6 +273,7 @@ PDB = Proto.clone().newSlots({
{
//this.debugWriteln("PDB.removeAt('" + k + "') ")
this.rememberKeyForUndo(k);
//writeln("out: ", k);
this._tc.out(k);
return this
},
Expand Down
8 changes: 4 additions & 4 deletions lib/Vertex/Vertex.js
Expand Up @@ -110,10 +110,10 @@ Vertex = Proto.clone().newSlots({
open: function()
{
this.pdb().setPath(this.path()).open();
/*
this.pdb().showRawKeyValues();
process.exit();
*/
/*
this.show();
process.exit();
*/
return this;
},

Expand Down

0 comments on commit 1fccc84

Please sign in to comment.