diff --git a/lib/request.js b/lib/request.js index ecf52a8..2f70e80 100644 --- a/lib/request.js +++ b/lib/request.js @@ -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; @@ -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); @@ -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 diff --git a/package.json b/package.json index 167dbc4..3626c51 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/test/request-test.js b/test/request-test.js index 47e0f4f..fb82c93 100644 --- a/test/request-test.js +++ b/test/request-test.js @@ -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,