扫码登录,获取cookies

This commit is contained in:
2026-03-09 16:10:29 +08:00
parent 754e720ba7
commit 8229208165
7775 changed files with 1150053 additions and 208 deletions

View File

@@ -0,0 +1 @@
pip

View File

@@ -0,0 +1,130 @@
Metadata-Version: 2.4
Name: httptools
Version: 0.7.1
Summary: A collection of framework independent HTTP protocol utils.
Author-email: Yury Selivanov <yury@magic.io>
License-Expression: MIT
Project-URL: Homepage, https://github.com/MagicStack/httptools
Platform: macOS
Platform: POSIX
Platform: Windows
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: POSIX
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Environment :: Web Environment
Classifier: Development Status :: 5 - Production/Stable
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Dynamic: license-file
Dynamic: platform
![Tests](https://github.com/MagicStack/httptools/workflows/Tests/badge.svg)
httptools is a Python binding for the nodejs HTTP parser.
The package is available on PyPI: `pip install httptools`.
# APIs
httptools contains two classes `httptools.HttpRequestParser`,
`httptools.HttpResponseParser` (fulfilled through
[llhttp](https://github.com/nodejs/llhttp)) and a function for
parsing URLs `httptools.parse_url` (through
[http-parse](https://github.com/nodejs/http-parser) for now).
See unittests for examples.
```python
class HttpRequestParser:
def __init__(self, protocol):
"""HttpRequestParser
protocol -- a Python object with the following methods
(all optional):
- on_message_begin()
- on_url(url: bytes)
- on_header(name: bytes, value: bytes)
- on_headers_complete()
- on_body(body: bytes)
- on_message_complete()
- on_chunk_header()
- on_chunk_complete()
- on_status(status: bytes)
"""
def get_http_version(self) -> str:
"""Return an HTTP protocol version."""
def should_keep_alive(self) -> bool:
"""Return ``True`` if keep-alive mode is preferred."""
def should_upgrade(self) -> bool:
"""Return ``True`` if the parsed request is a valid Upgrade request.
The method exposes a flag set just before on_headers_complete.
Calling this method earlier will only yield `False`.
"""
def feed_data(self, data: bytes):
"""Feed data to the parser.
Will eventually trigger callbacks on the ``protocol``
object.
On HTTP upgrade, this method will raise an
``HttpParserUpgrade`` exception, with its sole argument
set to the offset of the non-HTTP data in ``data``.
"""
def get_method(self) -> bytes:
"""Return HTTP request method (GET, HEAD, etc)"""
class HttpResponseParser:
"""Has all methods except ``get_method()`` that
HttpRequestParser has."""
def get_status_code(self) -> int:
"""Return the status code of the HTTP response"""
def parse_url(url: bytes):
"""Parse URL strings into a structured Python object.
Returns an instance of ``httptools.URL`` class with the
following attributes:
- schema: bytes
- host: bytes
- port: int
- path: bytes
- query: bytes
- fragment: bytes
- userinfo: bytes
"""
```
# Development
1. Clone this repository with
`git clone --recursive git@github.com:MagicStack/httptools.git`
2. Create a virtual environment with Python 3:
`python3 -m venv envname`
3. Activate the environment with `source envname/bin/activate`
4. Run `make` and `make test`.
# License
MIT.

View File

@@ -0,0 +1,25 @@
httptools-0.7.1.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
httptools-0.7.1.dist-info/METADATA,sha256=SDOnsarDrAxgLgiOHmAxC9OnA4Ca9XEeI6DB1McUYKU,3602
httptools-0.7.1.dist-info/RECORD,,
httptools-0.7.1.dist-info/WHEEL,sha256=JLOMsP7F5qtkAkINx5UnzbFguf8CqZeraV8o04b0I8I,101
httptools-0.7.1.dist-info/licenses/LICENSE,sha256=HAKLBZ16WOFMzaOMq87WmMWR_mFP--T3IUMERuhsjWk,1114
httptools-0.7.1.dist-info/top_level.txt,sha256=APjJKTbZcj0OQ4fdgf2eTCk82nK1n2BFXOD7ky41MPY,10
httptools/__init__.py,sha256=uWLIa0nghlhLGoS8My_6YVhUlFbv3FhYsvxYpZHecS8,153
httptools/__pycache__/__init__.cpython-311.pyc,,
httptools/__pycache__/_version.cpython-311.pyc,,
httptools/_version.py,sha256=L1qOIEGz2abHAuE9FSwFU6Q3tDr3nhuABOTtgE9ISv0,588
httptools/parser/__init__.py,sha256=mXOisHGQtSCaaFE1RNgTtEhEnqhMqi9jFWaAGSIUktY,207
httptools/parser/__pycache__/__init__.cpython-311.pyc,,
httptools/parser/__pycache__/errors.cpython-311.pyc,,
httptools/parser/__pycache__/protocol.cpython-311.pyc,,
httptools/parser/cparser.pxd,sha256=XOczyt3PFtYc1r-GVKecEkN5zvBD78NXfd2JhyKOKBg,5144
httptools/parser/errors.py,sha256=fQeEGiZ6AQH7SIa-7uzMs5QggoXr0A8YBPVHmafSw5Q,596
httptools/parser/parser.cp311-win_amd64.pyd,sha256=os7oiaUzd7meuH0nmw-R0wao-ww2iOz1-MJKxxRLId8,123392
httptools/parser/parser.pyi,sha256=ipY5DWsoBI-XSUw_GONH2l1WkG97vQlB6aSnE4ilmcI,1918
httptools/parser/parser.pyx,sha256=jgDH58PbHrXpT4wGDptP02tGsceOo9qHYSJBdpK5ZEs,15576
httptools/parser/protocol.py,sha256=tGhmbKw2mlmwWmfo400sugh9F6ghjBSG4R84OJEpR-4,557
httptools/parser/python.pxd,sha256=-pIXNLe1u3u3X51ORUUoHRBMsntzRlQa3z2iBqljTHU,144
httptools/parser/url_cparser.pxd,sha256=rvPJV7S96tTqKMT0Bk4jHgMy2U0rNY5_NsPa7KG5lio,810
httptools/parser/url_parser.cp311-win_amd64.pyd,sha256=xeTF3iqNMSZucJgnUpuE_t3ALKjjlS0dmdak5tZYfgo,50688
httptools/parser/url_parser.pyi,sha256=YFt6ooO5GGv_IG7-Mq1vZHi3jBIMWAquUv87TPyMTBU,592
httptools/parser/url_parser.pyx,sha256=_ZmJwXC2kh6Rh6FLQTy3nGBiZBBPAX9O-pWtGlgS-44,3866

View File

@@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: setuptools (80.9.0)
Root-Is-Purelib: false
Tag: cp311-cp311-win_amd64

View File

@@ -0,0 +1,21 @@
The MIT License
Copyright (c) 2015 MagicStack Inc. http://magic.io
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1 @@
httptools