Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

httparse

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httparse

Push parser for HTTP 1.x

  • 0.2.1
  • PyPI
  • Socket score

Maintainers
1

httparse

CI

Python wrapper for Rust's httparse. See this project on GitHub.

Example

from httparse import RequestParser

parser = RequestParser()

buff = b"GET /index.html HTTP/1.1\r\nHost"
parsed = parser.parse(buff)
assert parsed is None

# a partial request, so we try again once we have more data
buff = b"GET /index.html HTTP/1.1\r\nHost: example.domain\r\n\r\n"
parsed = parser.parse(buff)
assert parsed is not None
assert parsed.method == "GET"
assert parsed.path == "/index.html"
assert parsed.version == 1
assert parsed.body_start_offset == len(buff)
headers = [(h.name.encode(), h.value) for h in parsed.headers]
assert headers == [(b"Host", b"example.domain")]

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc