Show More
@@ -24,7 +24,7 b' class wsgirequest(object):' | |||
|
24 | 24 | self.run_once = wsgienv['wsgi.run_once'] |
|
25 | 25 | self.env = wsgienv |
|
26 | 26 | self.form = cgi.parse(self.inp, self.env, keep_blank_values=1) |
|
27 | self.start_response = start_response | |
|
27 | self._start_response = start_response | |
|
28 | 28 | self.headers = [] |
|
29 | 29 | |
|
30 | 30 | def __iter__(self): |
@@ -33,24 +33,31 b' class wsgirequest(object):' | |||
|
33 | 33 | def read(self, count=-1): |
|
34 | 34 | return self.inp.read(count) |
|
35 | 35 | |
|
36 | def start_response(self, status): | |
|
37 | if self._start_response is not None: | |
|
38 | if not self.headers: | |
|
39 | raise RuntimeError("request.write called before headers sent" + | |
|
40 | " (%s)." % thing) | |
|
41 | ||
|
42 | if isinstance(status, ErrorResponse): | |
|
43 | status = statusmessage(status.code) | |
|
44 | elif isinstance(status, int): | |
|
45 | status = statusmessage(status) | |
|
46 | ||
|
47 | self.server_write = self._start_response(status, self.headers) | |
|
48 | self._start_response = None | |
|
49 | self.headers = [] | |
|
50 | ||
|
36 | 51 | def respond(self, status, *things): |
|
52 | if not things: | |
|
53 | self.start_response(status) | |
|
37 | 54 | for thing in things: |
|
38 | 55 | if hasattr(thing, "__iter__"): |
|
39 | 56 | for part in thing: |
|
40 | 57 | self.respond(status, part) |
|
41 | 58 | else: |
|
42 | 59 | thing = str(thing) |
|
43 |
|
|
|
44 | if not self.headers: | |
|
45 | raise RuntimeError("request.write called before headers sent (%s)." % thing) | |
|
46 | if isinstance(status, ErrorResponse): | |
|
47 | status = statusmessage(status.code) | |
|
48 | elif isinstance(status, int): | |
|
49 | status = statusmessage(status) | |
|
50 | self.server_write = self.start_response(status, | |
|
51 | self.headers) | |
|
52 | self.start_response = None | |
|
53 | self.headers = [] | |
|
60 | self.start_response(status) | |
|
54 | 61 | try: |
|
55 | 62 | self.server_write(thing) |
|
56 | 63 | except socket.error, inst: |
General Comments 0
You need to be logged in to leave comments.
Login now