diff --git a/.gitignore b/.gitignore index 7fdea58..a48f783 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ *.pyc *.egg-info +build +dist +/.project +/.pydevproject diff --git a/hookbox/config.py b/hookbox/config.py index 304288f..51d68d0 100644 --- a/hookbox/config.py +++ b/hookbox/config.py @@ -86,6 +86,10 @@ def _add_callback_interface_options(self, parser, defaults): dest="cbhttps", action="store_true", default=defaults._cbhttps, metavar="HTTPS", help="Use https (instead of http) to make callbacks.") + parser.add_option("--cbtrailingslash", + dest="cbtrailingslash", action="store_true", + default=defaults._cbtrailingslash, + help="Append a trailing slash to the callback URL.") def _add_callback_path_options(self, parser, defaults): parser.add_option('--cb-connect', @@ -162,6 +166,7 @@ class HookboxConfig(object): defaults._cookie_identifier = NoDefault() defaults._webhook_secret = NoDefault() defaults._cbhttps = False + defaults._cbtrailingslash = False defaults._cb_connect = 'connect' defaults._cb_disconnect = 'disconnect' defaults._cb_create_channel = 'create_channel' diff --git a/hookbox/server.py b/hookbox/server.py index 655909b..a29f79b 100644 --- a/hookbox/server.py +++ b/hookbox/server.py @@ -158,10 +158,9 @@ def http_request(self, path_name=None, cookie_string=None, form={}, full_path=No full_path = self.config['cb_single_url'] if full_path: u = urlparse.urlparse(full_path) - scheme = u.scheme - host = u.hostname - port = u.port or 80 - path = u.path + scheme, host, port, path = u.scheme, u.hostname, u.port or 80, u.path + if self.config['cbtrailingslash'] and not path.endswith('/'): + path += '/' if u.query: path += '?' + u.query else: @@ -170,6 +169,8 @@ def http_request(self, path_name=None, cookie_string=None, form={}, full_path=No # host = self.base_host # else: path = self.base_path + '/' + self.config.get('cb_' + path_name) + if self.config['cbtrailingslash'] and not path.endswith('/'): + path += '/' scheme = self.config["cbhttps"] and "https" or "http" host = self.config["cbhost"] port = self.config["cbport"] @@ -194,11 +195,9 @@ def http_request(self, path_name=None, cookie_string=None, form={}, full_path=No # for logging if port != 80: - url = urlparse.urlunparse((scheme,host + ":" + str(port), '', '','','')) - else: - url = urlparse.urlunparse((scheme,host, '', '','','')) - - + host = "%s:%s" % (host, port) + url = urlparse.urlunparse((scheme, host, '', '', '', '')) + headers = {'content-type': 'application/x-www-form-urlencoded'} if cookie_string: headers['Cookie'] = cookie_string diff --git a/hookbox/user.py b/hookbox/user.py index 254b796..30c46ba 100644 --- a/hookbox/user.py +++ b/hookbox/user.py @@ -13,6 +13,7 @@ class User(object): _options = { 'reflective': True, 'moderated_message': True, + 'auto_subscribe':[] } def __init__(self, server, name, **options):