Comments (5)
My current approach is:
- Inspect
upgrade
header inon_header
. - Ignore any events in
on_body
andon_message
complete if an upgrade header existed. - Handle the
httptools.HttpParserUpgrade
indata_received
as normally.
That works fine, only downside being a small amount of extra work in Python-land that could perhaps be dealt with by the parser, if the exception was raised prior to the event hooks being called.
I guess good options would be:
- Close this off as a known constraint.
- Ensure that
httpparser
instead raises the exception immediately prior to the point of callingon_headers_complete
.
from httptools.
Okay, looks like this is a limitation of the underlying library...
the parser will treat this as a normal HTTP message without a body, issuing both on_headers_complete and on_message_complete callbacks
I'll close the issue off.
from httptools.
hi. also got HttpParserUpgrade when parsing
b'CONNECT /proxy/url HTTP/1.1\r\nHost: test01-proxy.com:80\r\nAuthorization: Basic dXNlcjpwYXNz\r\nX-Forwarded-For: 8.8.8.8\r\n\r\n'
In [60]: b = b'CONNECT /proxy/url HTTP/1.1\r\nHost: test01-proxy.com:80\r\nAuthorization: Basic dXNlcjpwYXNz\r\nX-Forwarded-For: 8.8.8.8\r\n\r\n'
In [61]: p = HttpRequestParser (lambda: None)
In [62]: p.feed_data(b)
---------------------------------------------------------------------------
HttpParserUpgrade Traceback (most recent call last)
<ipython-input-62-032eaec4cf5a> in <module>()
----> 1 p.feed_data(b)
httptools/parser/parser.pyx in httptools.parser.parser.HttpParser.feed_data (httptools/parser/parser.c:2781)()
HttpParserUpgrade: 119
if replace the b'\r\n\r\n' with b\r\n' the error is disappears
made more tests. parsing the request above and even replacing '\r\n\r\n' not works correctly: callback functions such as on_message_complete, on_headers_complete not fired at all.
just replacing the b'CONNECT' with b'GET' without other modifications makes all working.
from httptools.
cf #29 for the record
from httptools.
@ramonz I think it's expected behaviour, see https://github.com/nodejs/http-parser/blob/0264a0aefcd119e179a3bc730ac517efbbccd4bb/http_parser.c#L1319
from httptools.
Related Issues (20)
- API change from 0.0.13->0.1.1 HOT 2
- Deprecation warnings in Python 3.10 HOT 3
- Wheel support for linux aarch64 HOT 1
- provide wheel for python3.9 HOT 9
- Note: httptools 0.0.13 from PyPI is incompatible with Python 3.9
- PROXY protocol v1 / v2 support
- [Security] Potential Secret Leak HOT 1
- Silent fail of long url parsing HOT 2
- Git release/tag for 0.2.0 pypi version HOT 2
- Wheels for httptools 0.2.0 on Python 3.10 HOT 1
- CVE-2021-22959 & CVE-2021-22960
- Doesn't build against Python 3.11 HOT 3
- Fail to get wheel for python 3.9.5 when pip install
- llhttp critical CVE's HOT 4
- How to do an early stop? HOT 2
- . HOT 1
- with curl and https HOT 1
- Error installing httptools as a uvicorn dependency HOT 2
- Create wheel for Python 3.12 HOT 1
- Support Cython 3.0+ HOT 2
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 httptools.