Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request.content raises error #34

Closed
frostming opened this issue Oct 14, 2018 · 0 comments
Closed

Request.content raises error #34

frostming opened this issue Oct 14, 2018 · 0 comments

Comments

@frostming
Copy link
Contributor

Minimal example:

@api.route('/')
async def index(req, resp):
    print(await req.content)
    resp.text = 'Hello world'

When visit index page, error pops:

raceback (most recent call last):
  File "/Users/fming/.local/share/virtualenvs/responder-l5YZbUOR/lib/python3.7/site-packages/uvicorn/protocols/http/h11_impl.py", line 394, in run_asgi
    result = await asgi(self.receive, self.send)
  File "/Users/fming/.local/share/virtualenvs/responder-l5YZbUOR/lib/python3.7/site-packages/uvicorn/middleware/message_logger.py", line 52, in __call__
    await inner(self.receive, self.send)
  File "/Users/fming/wkspace/github/responder/responder/api.py", line 83, in asgi
    resp = await self._dispatch_request(req)
  File "/Users/fming/wkspace/github/responder/responder/api.py", line 114, in _dispatch_request
    await result
  File "test_app.py", line 9, in index
    print(await req.content)
  File "/Users/fming/wkspace/github/responder/responder/models.py", line 133, in content
    return (await self._starlette.body()).encode(self.encoding)
AttributeError: 'bytes' object has no attribute 'encode'

And moreover, there is no encoding attribute in Request object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant