Skip to content

Commit

Permalink
Merge pull request mashery#21 from nathanwdavis/master
Browse files Browse the repository at this point in the history
HTTPS support
  • Loading branch information
mansilladev committed Aug 2, 2012
2 parents 8e408c2 + 301a2e4 commit 0c01913
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app.js
Expand Up @@ -31,6 +31,7 @@ var express = require('express'),
query = require('querystring'),
url = require('url'),
http = require('http'),
https = require('https'),
crypto = require('crypto'),
redis = require('redis'),
RedisStore = require('connect-redis')(express);
Expand Down Expand Up @@ -521,8 +522,18 @@ function processRequest(req, res, next) {
console.log(util.inspect(options));
};

var doRequest;
if (options.protocol === 'https' || options.protocol === 'https:') {
console.log('Protocol: HTTPS');
options.protocol = 'https:'
doRequest = https.request;
} else {
console.log('Protocol: HTTP');
doRequest = http.request;
}

// API Call. response is the response from the API, res is the response we will send back to the user.
var apiCall = http.request(options, function(response) {
var apiCall = doRequest(options, function(response) {
response.setEncoding('utf-8');
if (config.debug) {
console.log('HEADERS: ' + JSON.stringify(response.headers));
Expand Down

0 comments on commit 0c01913

Please sign in to comment.