##// END OF EJS Templates
vcsserver: added stream EchoApp for testing
marcink -
r248:55f1a734 default
parent child Browse files
Show More
@@ -1,34 +1,54 b''
1 1 """
2 2 Implementation of :class:`EchoApp`.
3 3
4 4 This WSGI application will just echo back the data which it recieves.
5 5 """
6 6
7 7 import logging
8 8
9 9
10 10 log = logging.getLogger(__name__)
11 11
12 12
13 13 class EchoApp(object):
14 14
15 15 def __init__(self, repo_path, repo_name, config):
16 16 self._repo_path = repo_path
17 17 log.info("EchoApp initialized for %s", repo_path)
18 18
19 19 def __call__(self, environ, start_response):
20 20 log.debug("EchoApp called for %s", self._repo_path)
21 21 log.debug("Content-Length: %s", environ.get('CONTENT_LENGTH'))
22 22 environ['wsgi.input'].read()
23 23 status = '200 OK'
24 24 headers = [('Content-Type', 'text/plain')]
25 25 start_response(status, headers)
26 26 return ["ECHO"]
27 27
28 28
29 class EchoAppStream(object):
30
31 def __init__(self, repo_path, repo_name, config):
32 self._repo_path = repo_path
33 log.info("EchoApp initialized for %s", repo_path)
34
35 def __call__(self, environ, start_response):
36 log.debug("EchoApp called for %s", self._repo_path)
37 log.debug("Content-Length: %s", environ.get('CONTENT_LENGTH'))
38 environ['wsgi.input'].read()
39 status = '200 OK'
40 headers = [('Content-Type', 'text/plain')]
41 start_response(status, headers)
42
43 def generator():
44 for _ in xrange(1000000):
45 yield "ECHO"
46 return generator()
47
48
29 49 def create_app():
30 50 """
31 51 Allows to run this app directly in a WSGI server.
32 52 """
33 53 stub_config = {}
34 54 return EchoApp('stub_path', 'stub_name', stub_config)
General Comments 0
You need to be logged in to leave comments. Login now