-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwisted_runner.py
More file actions
39 lines (27 loc) · 870 Bytes
/
Copy pathtwisted_runner.py
File metadata and controls
39 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
fixed ssl with "acceptableProtocols in twisted, see this:"
http://twisted.readthedocs.org/en/latest/core/howto/ssl.html
"""
import os
#twisted imports
from twisted.internet import reactor
from twisted.internet.endpoints import connectProtocol, SSL4ClientEndpoint
from twisted.internet.ssl import optionsForClientTLS
# my twisted files
from twisted_client import H2Protocol
# for passing messages
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
from messageHandler import messageHandler
SIZE = 4096
AUTHORITY = u'twitter.com'
PATH = '/'
def run(messagehandler):
options = optionsForClientTLS(
hostname=AUTHORITY,
acceptableProtocols=[b'h2', b'http/1.1'],
)
connectProtocol(
SSL4ClientEndpoint(reactor, AUTHORITY, 443, options),
H2Protocol(messagehandler)
)
reactor.run(installSignalHandlers=0)