MCPcopy
hub / github.com/aio-libs/aiohttp / handle_request

Method handle_request

aiohttp/server.py:371–397  ·  view source on GitHub ↗

Handle a single HTTP request. Subclass should override this method. By default it always returns 404 response. :param message: Request headers :type message: aiohttp.protocol.HttpRequestParser :param payload: Request payload :type payload: aiohttp.st

(self, message, payload)

Source from the content-addressed store, hash-verified

369 self.keep_alive(False)
370
371 def handle_request(self, message, payload):
372 """Handle a single HTTP request.
373
374 Subclass should override this method. By default it always
375 returns 404 response.
376
377 :param message: Request headers
378 :type message: aiohttp.protocol.HttpRequestParser
379 :param payload: Request payload
380 :type payload: aiohttp.streams.FlowControlStreamReader
381 """
382 now = self._loop.time()
383 response = aiohttp.Response(
384 self.writer, 404, http_version=message.version, close=True)
385
386 body = b'Page Not Found!'
387
388 response.add_header(hdrs.CONTENT_TYPE, 'text/plain')
389 response.add_header(hdrs.CONTENT_LENGTH, str(len(body)))
390 response.send_headers()
391 response.write(body)
392 drain = response.write_eof()
393
394 self.keep_alive(False)
395 self.log_access(message, None, response, self._loop.time() - now)
396
397 return drain

Callers 1

startMethod · 0.95

Calls 6

write_eofMethod · 0.95
keep_aliveMethod · 0.95
log_accessMethod · 0.95
add_headerMethod · 0.80
send_headersMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected