Comments (7)
Would be better if we can add a test to test_parser.py reproducing the problem. Also, does it work without C parser (AIOHTTP_NO_EXTENSIONS=1
)?
from aiohttp.
With AIOHTTP_NO_EXTENSIONS=1
there seems to be no issue
from aiohttp.
Then it likely needs a bug report at https://github.com/nodejs/llhttp/ with the actual message that trips the parser (they will need to reproduce it in isolation, without aiohttp or tlsanvil).
from aiohttp.
I've narrowed the issue a bit down. It has to do with the Upgrade: h2c
header in the request. A more minimal reproduction example:
Server
import aiohttp.web
async def printer(request):
print(request.path, await request.read())
return aiohttp.web.json_response({})
app = aiohttp.web.Application()
app.router.add_post("/", printer)
aiohttp.web.run_app(app, port=8000)
Client
import socket
import time
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 0)
sock.connect(("localhost", 8000))
sock.send(b"POST / HTTP/1.1\r\n"
b"Connection: Upgrade\r\n"
b"Content-Length: 2\r\n"
b"Upgrade: h2c\r\n"
b"Content-Type: application/json\r\n\r\n"
b"{}")
print(sock.recv(1024))
sock.close()
from aiohttp.
If you still think it is an issue with llhttp
, could you open an issue over there? I'm not familiar with that project, so the bug report would probably be not too precise and helpful.
from aiohttp.
We are faced with the same problem: http-body gets mangled.
aiohttp 3.9.3 works.
from aiohttp.
I see the same result in 3.8. Test reproducer is:
def test_http_request_parser_upgrade(parser: Any) -> None:
text = b"POST / HTTP/1.1\r\nConnection: Upgrade\r\nContent-Length: 2\r\nUpgrade: h2c\r\nContent-Type: application/json\r\n\r\n"
msg = parser.feed_data(text)[0][0][0]
assert parser.feed_data(b"{}") == ([], False, b"")
assert msg.method == "POST"
assert msg.path == "/"
assert msg.url.path == "/"
assert msg.version == (1, 1)
assert not msg.should_close
assert msg.compression is None
assert msg.upgrade
assert not msg.chunked
It only happens when the message is split over 2 feed_data() calls though.
from aiohttp.
Related Issues (20)
- ValueError: I/O operation on closed file on WSL HOT 2
- Security improvement: raise_for_status + ClientError prevent tokens from leaking HOT 5
- aiohttp does not support concurrent requests exceeding 500.
- Termux aiohttp could not build wheels for aiohttp HOT 5
- aiohttp cannot make HTTPS (SSL) requests in a Windows container HOT 9
- DNS over HTTPS (DoH) HOT 1
- Unmonitored websocket task triggers false errors in logs HOT 1
- Documentation not working HOT 1
- https://docs.aiohttp.org/ has been defaced/squatted HOT 1
- aiohttp.org site is down HOT 1
- Server; POST-request; BadStatusLine: 400; an endless stream of exception messages that have no impact on operation.
- Broken timeout system with ws_connect HOT 1
- graceful shutdown order and cleanup contexts HOT 7
- ValueError: I/O operation on closed file in aiohttp payload size property on file uploading using form HOT 1
- Allow reading already retrieved response body after connection is closed
- Support for sending Trailer headers HOT 2
- Separate exception for DNS errors
- Weak Etag can not trigger negotiation caching
- The set request parameters were not used HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiohttp.