The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#) https://grpc.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.7 KiB

8 years ago
"""
HTTP2 Test Server. Highly experimental work in progress.
"""
import argparse
import logging
8 years ago
from twisted.internet.protocol import Factory
from twisted.internet import endpoints, reactor
8 years ago
import http2_base_server
8 years ago
import test_rst_after_header
import test_rst_after_data
import test_goaway
import test_ping
import test_max_streams
8 years ago
class H2Factory(Factory):
def __init__(self, testcase):
logging.info('In H2Factory')
self._num_streams = 0
self._testcase = testcase
def buildProtocol(self, addr):
self._num_streams += 1
8 years ago
logging.info('New Connection: %d'%self._num_streams)
8 years ago
if self._testcase == 'rst_after_header':
t = test_rst_after_header.TestcaseRstStreamAfterHeader()
elif self._testcase == 'rst_after_data':
t = test_rst_after_data.TestcaseRstStreamAfterData()
8 years ago
elif self._testcase == 'goaway':
8 years ago
t = test_goaway.TestcaseGoaway(self._num_streams)
8 years ago
elif self._testcase == 'ping':
8 years ago
t = test_ping.TestcasePing()
elif self._testcase == 'max_streams':
t = test_max_streams.TestcaseSettingsMaxStreams()
8 years ago
else:
8 years ago
logging.error('Unknown test case: %s'%self._testcase)
8 years ago
assert(0)
return t.get_base_server()
if __name__ == "__main__":
logging.basicConfig(format = "%(levelname) -10s %(asctime)s %(module)s:%(lineno)s | %(message)s", level=logging.INFO)
parser = argparse.ArgumentParser()
parser.add_argument("test")
parser.add_argument("port")
args = parser.parse_args()
8 years ago
if args.test not in ['rst_after_header', 'rst_after_data', 'goaway', 'ping', 'max_streams']:
8 years ago
print 'unknown test: ', args.test
endpoint = endpoints.TCP4ServerEndpoint(reactor, int(args.port), backlog=128)
endpoint.listen(H2Factory(args.test))
reactor.run()