Skip to main content

(RHParse)Raw HTTP Parse 原始HTTP数据包解析器

Raw HTTP Parse 是一个简单易用的 Python 库,用于将原始 HTTP 数据包解析为 requests.Request 对象,以及将 requests.Response 对象格式化为原始 HTTP 响应字符串。

安装

pip install rhparse

使用

from rhparse import RHParse
import requests
# 解析原始 HTTP 请求
raw_request = """POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json

{"name": "张三"}
"""
request = RHParse.parse_request(raw_request)
print(request.url)  # 输出: http://example.com/api/users
print(request.data)  # 输出: {'name': '张三'}

# 使用requests库发起请求
session = requests.session()
res = session.send(request.prepare())
print(res.text)

# 格式化 HTTP 响应
import requests
response = requests.get("https://example.com")
raw_response = RHParse.format_response(response)
print(raw_response)  # 输出原始 HTTP 响应字符串

功能特点

  • 支持常见的 HTTP 方法(GET、POST、PUT 等)
  • 自动处理 Cookie 和 Authorization 头
  • 支持 JSON 和表单格式的请求体
  • 简洁的静态方法调用,无需实例化

许可证

MIT

Metadata

Release files for rhparse 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rhparse 0.0.2
File Size Uploaded Provenance Actions
rhparse-0.0.2.tar.gz 4.4 kB Without provenance Details for rhparse-0.0.2.tar.gz

Release files / rhparse-0.0.2.tar.gz

Download URL rhparse-0.0.2.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d76a645b93cfa4c1a90fc4c175aa1ca8e65c634cae4ac942397c9020ff688084
BLAKE2b-256 checksum
How to use checksums
da7895c2621a71b081c4ab7493845250b8f79bfa52536a723dcc294d435830df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Security for rhparse 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page