diff --git a/src/page_exporter/__init__.py b/src/page_exporter/__init__.py index 007cc69..8b653de 100644 --- a/src/page_exporter/__init__.py +++ b/src/page_exporter/__init__.py @@ -3,7 +3,7 @@ import os NAME = 'django_page_exporter'.replace('_', '-') -VERSION = __version__ = (0, 3, 1, 'final', 0) +VERSION = __version__ = (0, 4, 0, 'alpha', 0) __author__ = 'Marco Immediato' diff --git a/src/page_exporter/scripts/capture.js b/src/page_exporter/scripts/capture.js index 6d27363..0687322 100644 --- a/src/page_exporter/scripts/capture.js +++ b/src/page_exporter/scripts/capture.js @@ -87,7 +87,8 @@ if (config.cookie_name != null) { phantom.addCookie({ 'name': config.cookie_name || 'sessionid', 'value': config.cookie_value || '', - 'domain': config.cookie_domain || 'localhost' + 'domain': config.cookie_domain || 'localhost', + 'secure': config.cookie_secure || false }); } @@ -133,5 +134,7 @@ page.open(address, function (status) { } + }else if(status == 'fail'){ + phantom.exit(); } }); \ No newline at end of file diff --git a/src/page_exporter/utils.py b/src/page_exporter/utils.py index 8b7f8e1..e909a38 100644 --- a/src/page_exporter/utils.py +++ b/src/page_exporter/utils.py @@ -1,5 +1,6 @@ from threading import Timer +from django.conf import settings from django.utils import six import os import logging @@ -42,6 +43,7 @@ def phantomjs_command_kwargs(): def phantomjs_command(): cmd = conf.PHANTOMJS_CMD cmd = [cmd] + cmd_optz = conf.CLI_ARGS # Concatenate with capture script app_path = os.path.dirname(__file__) @@ -51,7 +53,8 @@ def phantomjs_command(): capture = os.path.join(app_path, 'scripts', capture) assert os.path.exists(capture), 'Cannot find %s' % capture - return cmd + [capture] + + return cmd + cmd_optz + [capture] PHANTOMJS_CMD = phantomjs_command() @@ -97,6 +100,9 @@ def page_capture(stream, url, method=None, width=None, height=None, cmd += ['--cookie_domain=%s' % cookie_domain] if page_status: cmd += ['--page_status=%s' % page_status] + if getattr(settings, 'SESSION_COOKIE_SECURE', False): + cmd += ['--cookie_secure=true'] + logger.debug(cmd) # Run PhantomJS process proc = subprocess.Popen(cmd, **phantomjs_command_kwargs()) diff --git a/tests/example_client/settings/default.py b/tests/example_client/settings/default.py index 87c2bad..b175d54 100644 --- a/tests/example_client/settings/default.py +++ b/tests/example_client/settings/default.py @@ -90,4 +90,7 @@ PAGE_EXPORTER_PHANTOMJS_CMD = os.path.join(os.path.dirname(__file__), '..', 'phantomjs', 'phantomjs') +PAGE_EXPORTER_WAIT = '10000' +PAGE_EXPORTER_CLI_ARGS = ['--ignore-ssl-errors=true', '--ssl-protocol=any'] + from .logging_conf import * # noqa