Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/request.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

var util = require('util');
var http = require('http');
var https = require('https');
var parameters = require('./parameters');
var ApiHttpError = require('./errors').ApiHttpError;
var OAuthError = require('./errors').OAuthError;
Expand Down Expand Up @@ -204,7 +204,7 @@ function dispatchSecure(path, httpMethod, requestData, headers, authtype,
function dispatch(url, httpMethod, data, headers, hostInfo, credentials,
logger, callback) {

hostInfo.port = hostInfo.port || 80;
hostInfo.port = hostInfo.port || 443;

var apiRequest, prop, hasErrored;
var mergedHeaders = createHeaders(hostInfo.host, headers);
Expand All @@ -222,17 +222,17 @@ function dispatch(url, httpMethod, data, headers, hostInfo, credentials,
url = url + '?' + qs.stringify(data);
}

logger.info(util.format('%s: http://%s:%s%s', httpMethod,
logger.info(util.format('%s: https://%s:%s%s', httpMethod,
hostInfo.host, hostInfo.port, url));
logHeaders(logger, mergedHeaders);

// Make the request
apiRequest = http.request({
apiRequest = https.request({
method: httpMethod,
hostname: hostInfo.host,
// Force scheme to http for browserify otherwise it will pick up the
// scheme from window.location.protocol which is app:// in firefoxos
scheme: 'http',
scheme: 'https',
// Set this so browserify doesn't set it to true on the xhr, which
// causes an http status of 0 and empty response text as it forces
// the XHR to do a pre-flight access-control check and the API
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "7digital-api",
"version": "1.0.0",
"version": "1.1.0",
"description": "7digital API client for nodeJS",
"homepage": "https://github.com/7digital/7digital-api",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion test/request-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('request', function () {
it('calls back with the error', function (done) {
var logger = { info: _.noop, error: _.noop };
var hostInfo = {
port: 80,
port: 443,
host: 'wibble'
};
request.dispatch('', 'GET', {}, {}, hostInfo, {}, logger,
Expand Down