Skip to content

Commit

Permalink
Merge pull request #22 from ebensing/master
Browse files Browse the repository at this point in the history
http.createClient -> http.request
  • Loading branch information
silentrob committed Jul 26, 2012
2 parents 7513d3d + 7c4d25b commit e5d0c71
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/apricot.js
Expand Up @@ -319,20 +319,21 @@ Apricot.open = function(file, callback, live) {


if (file.match(/^https?:\/\//)) { if (file.match(/^https?:\/\//)) {
var urlInfo = url.parse(file, parseQueryString=false), var urlInfo = url.parse(file, parseQueryString=false),
host = http.createClient(((urlInfo.protocol === 'http:') ? urlInfo.port || 80 : 443), urlInfo.hostname), //host = http.createClient(((urlInfo.protocol === 'http:') ? urlInfo.port || 80 : 443), urlInfo.hostname),
req_url = urlInfo.pathname; req_url = urlInfo.pathname;


if (urlInfo.search) { if (urlInfo.search) {
req_url += urlInfo.search; req_url += urlInfo.search;
} }
var request = host.request('GET', req_url, { host: urlInfo.hostname, "User-Agent": "Apricot" }); var request = http.request({method: 'GET', host: urlInfo.hostname, path : urlInfo.pathname, "User-Agent": "Apricot"});



request.addListener('response', function (response) { request.on('response', function (response) {
var data = ''; var data = '';
response.addListener('data', function (chunk) { response.on('data', function (chunk) {
data += chunk; data += chunk;
}); });
response.addListener("end", function() { response.on("end", function() {
fnLoaderHandle(null, data); fnLoaderHandle(null, data);
}); });
}); });
Expand Down Expand Up @@ -377,4 +378,4 @@ hasClass = function(el, className) {


trim = function(text) { trim = function(text) {
return (text || "").replace( rtrim, "" ); return (text || "").replace( rtrim, "" );
}; };

0 comments on commit e5d0c71

Please sign in to comment.