Skip to main content

parserheader

Parsing headers from string or dictionary

Installing

Install and update using pip:

    $ pip install parserheader

parserheader supports Python 2 and newer, Python 3 and newer, and PyPy.

Example

What does it look like? Here is an example of a simple parserheader program:

    import parserheader
    
    ...

    def setHeaders():
        ph = parserheader.parserheader()
        header_str = """
            POST /upload/ HTTP/1.1
            Host: google.com.com
            Connection: keep-alive
            Content-Length: 1220
            Cache-Control: max-age=0
            Origin: http://www.google.com.com
            Upgrade-Insecure-Requests: 1
            Content-Type: application/x-www-form-urlencoded
            User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
            Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
            Referer: http://www.google.com/
            Accept-Encoding: gzip, deflate
            Accept-Language: en-US,en;q=0.9,id;q=0.8
            Cookie: PHPSESSID=41a0f0ac4545d3f5ba9a4ba415b777e9
        """
        headers = ph.parserHeader(header_str)
        print("headers =", headers)
        return headers

    setHeaders()

And what it looks like when run:

    $ python test.py 
    headers = {'Origin': 'http://www.google.com', 'Content-Length': '1220', 'Accept-Language': 'en-US,en;q=0.9,id;q=0.8', 'Accept-Encoding': 'gzip, deflate', 'Connection': 'keep-alive', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36', 'Host': 'google.com', 'Referer': 'http://www.google.com/', 'Cache-Control': 'max-age=0', 'Cookie': 'PHPSESSID=41a0f0ac4545d3f5ba9a4ba415b777e9', 'Upgrade-Insecure-Requests': '1', 'Content-Type': 'application/x-www-form-urlencoded'}

Support

  • Python 2.7 +, Python 3.x
  • Windows, Linux

Links

Author

Hadi Cahyadi

Buy Me a Coffee

Donate via Ko-fi Support me on Patreon

Metadata

Release files for parserheader 0.38.3

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

Source distribution (sdist)

Source distribution for parserheader 0.38.3
File Size Uploaded Provenance
parserheader-0.38.3.tar.gz 7.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for parserheader 0.38.3
File Interpreter ABI Platform
parserheader-0.38.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 15.9 kB

Release files / parserheader-0.38.3.tar.gz

Download URL parserheader-0.38.3.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
14c145226edd2eb0d6661e347cce35656a18fe30f94dd101004065b65735eb7a
BLAKE2b-256 checksum
How to use checksums
89f545deee58891e82e44edc572c139122befc8186d18e6eb44e363eeb0b2cac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Release files / parserheader-0.38.3-py2.py3-none-any.whl

Download URL parserheader-0.38.3-py2.py3-none-any.whl
Size 8.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
9270d559780c8f480aeca4fccdcd2e9242694169c4ff0f35b9643fedb28b6b52
BLAKE2b-256 checksum
How to use checksums
e17fe89ca9f36f7fa843c674814542d8834d38374e8a17e80b38bb6440a18271
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.4

Security for parserheader 0.38.3

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.

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