An error occurred when publishing a static file using uvloop #5149
Closed
Description
🐞 Describe the bug
An error occurred when publishing a static file using aiohttp 3.7.x and uvloop.
💡 To Reproduce
# Dockerfile
FROM python:3.8.6
WORKDIR /work
RUN pip install aiohttp==3.7.1 uvloop==0.14.0
ADD app.py .
RUN mkdir static && echo "/* DUMMY */" > static/index.css
CMD ["python", "app.py"]# app.py
import uvloop
from aiohttp import web
uvloop.install()
app = web.Application()
app.add_routes([web.static("/static", "/work/static")])
if __name__ == "__main__":
web.run_app(app)Then, build and run server.
$ docker build . -t tmp
$ docker run --rm -it -p 8080:8080 tmpFinally, try to access http://localhost:8080/static/index.css .
When accessed from a browser, the following error is displayed in the developer console.
net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
When accessed from a cURL, the following error is displayed.
curl: (18) transfer closed with 12 bytes remaining to read
It looks like the connection was closed before sending the response body.
💡 Expected behavior
No error occurs.
📋 Logs/tracebacks
No messages are displayed in the Python log at all.
📋 Your version of the Python
$ docker run --rm tmp python --version
Python 3.8.6📋 Your version of the aiohttp/yarl/multidict distributions
$ docker run --rm tmp python -m pip show aiohttp
Name: aiohttp
Version: 3.7.1
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: Nikolay Kim
Author-email: fafhrd91@gmail.com
License: Apache 2
Location: /usr/local/lib/python3.8/site-packages
Requires: chardet, multidict, attrs, async-timeout, typing-extensions, yarl
Required-by:$ docker run --rm tmp python -m pip show multidict
Name: multidict
Version: 5.0.0
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /usr/local/lib/python3.8/site-packages
Requires:
Required-by: yarl, aiohttp$ docker run --rm tmp python -m pip show yarl
Name: yarl
Version: 1.6.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /usr/local/lib/python3.8/site-packages
Requires: idna, multidict
Required-by: aiohttp📋 Additional context
- When aiphttp==3.6.*, it works fine
- When uvloop disabled, it works fine