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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
*.pyc
*.egg-info
build
dist
/.project
/.pydevproject
5 changes: 5 additions & 0 deletions hookbox/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand Down
17 changes: 8 additions & 9 deletions hookbox/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"]
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions hookbox/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class User(object):
_options = {
'reflective': True,
'moderated_message': True,
'auto_subscribe':[]
}

def __init__(self, server, name, **options):
Expand Down