|
19 | 19 | app_id_re = re.compile('^[0-9]+$') |
20 | 20 |
|
21 | 21 | def url2options(url): |
| 22 | + port = None |
22 | 23 | if url.startswith('http://'): |
23 | 24 | url = url[7:] |
| 25 | + port = 80 |
24 | 26 | elif url.startswith('https://'): |
25 | 27 | url = url[8:] |
| 28 | + port = 443 |
26 | 29 | else: |
27 | 30 | assert False, "invalid URL" |
28 | 31 | key, url = url.split(':', 1) |
29 | 32 | secret, url = url.split('@', 1) |
30 | 33 | host, url = url.split('/', 1) |
31 | 34 | url, app_id = url.split('/', 1) |
32 | | - return {'key': key, 'secret': secret, 'host': host, 'app_id': app_id} |
| 35 | + return {'key': key, 'secret': secret, 'host': host, 'app_id': app_id, 'port': port } |
33 | 36 |
|
34 | 37 | def pusher_from_url(url=None): |
35 | 38 | url = url or os.environ['PUSHER_URL'] |
@@ -97,7 +100,10 @@ def compose_querystring(self, event, json_data, socket_id): |
97 | 100 | return ret |
98 | 101 |
|
99 | 102 | def send_request(self, signed_path, data_string, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): |
100 | | - http = httplib.HTTPConnection(self.pusher.host, self.pusher.port, timeout=timeout) |
| 103 | + if self.pusher.port == 443: |
| 104 | + http = httplib.HTTPSConnection(self.pusher.host, self.pusher.port, timeout=timeout) |
| 105 | + else: |
| 106 | + http = httplib.HTTPConnection(self.pusher.host, self.pusher.port, timeout=timeout) |
101 | 107 | http.request('POST', signed_path, data_string, {'Content-Type': 'application/json'}) |
102 | 108 | resp = http.getresponse() |
103 | 109 | return resp.status, resp.read() |
|
0 commit comments