Handle a single HTTP request
(self, message, payload)
| 131 | |
| 132 | @asyncio.coroutine |
| 133 | def handle_request(self, message, payload): |
| 134 | """Handle a single HTTP request""" |
| 135 | now = self._loop.time() |
| 136 | |
| 137 | if self.readpayload: |
| 138 | wsgiinput = io.BytesIO() |
| 139 | wsgiinput.write((yield from payload.read())) |
| 140 | wsgiinput.seek(0) |
| 141 | payload = wsgiinput |
| 142 | |
| 143 | environ = self.create_wsgi_environ(message, payload) |
| 144 | response = self.create_wsgi_response(message) |
| 145 | |
| 146 | riter = self.wsgi(environ, response.start_response) |
| 147 | if isinstance(riter, asyncio.Future) or inspect.isgenerator(riter): |
| 148 | riter = yield from riter |
| 149 | |
| 150 | resp = response.response |
| 151 | try: |
| 152 | for item in riter: |
| 153 | if isinstance(item, asyncio.Future): |
| 154 | item = yield from item |
| 155 | yield from resp.write(item) |
| 156 | |
| 157 | yield from resp.write_eof() |
| 158 | finally: |
| 159 | if hasattr(riter, 'close'): |
| 160 | riter.close() |
| 161 | |
| 162 | if resp.keep_alive(): |
| 163 | self.keep_alive(True) |
| 164 | |
| 165 | self.log_access( |
| 166 | message, environ, response.response, self._loop.time() - now) |
| 167 | |
| 168 | |
| 169 | class FileWrapper: |
nothing calls this directly
no test coverage detected