Skip to content

AttributeError: 'StreamResponse' object has no attribute 'body' exception occurs when serving static html #12

@rutsky

Description

@rutsky

Steps to reproduce:

  1. Setup official demo: https://github.com/aio-libs/aiohttp_debugtoolbar/blob/master/demo/README.rst

  2. Create empty HTML file in static files directory:

    $ touch demo/static/test.html
  3. Start demo:

    $ python demo/demo.py
  4. Open http://localhost:9000/static/test.html in browser.

Expected behavior: empty html is being rendered in the browser and no errors occurs.
Observed behavior: empty html is being rendered in the browser, but in the console following stack trace occurs:

$ python demo/demo.py 
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:demo/demo.py:Server started at http://127.0.0.1:9000
ERROR:aiohttp.web:Error handling request
Traceback (most recent call last):
  File "/home/bob/stuff/aiohttp_debugtoolbar/demo/aiohttp_debugtoolbar/lib/python3.4/site-packages/aiohttp/server.py", line 272, in start
    yield from self.handle_request(message, payload)
  File "/home/bob/stuff/aiohttp_debugtoolbar/demo/aiohttp_debugtoolbar/lib/python3.4/site-packages/aiohttp/web.py", line 85, in handle_request
    resp = yield from handler(request)
  File "/home/bob/stuff/aiohttp_debugtoolbar/aiohttp_debugtoolbar/middlewares.py", line 141, in toolbar_middleware
    toolbar.inject(request, response)
  File "/home/bob/stuff/aiohttp_debugtoolbar/aiohttp_debugtoolbar/toolbar.py", line 57, in inject
    response_html = response.body
AttributeError: 'StreamResponse' object has no attribute 'body'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions