Skip to content

Commit

Permalink
HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonmwest committed Aug 25, 2013
1 parent 5a50cbe commit b02ec8a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var express = require('express'),
query = require('querystring'),
url = require('url'),
http = require('http'),
https = require('https'),
redis = require('redis'),
RedisStore = require('connect-redis')(express),
hashlib = require('hashlib');
Expand Down Expand Up @@ -508,8 +509,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 b02ec8a

Please sign in to comment.