💡Python package for HTTP/1.1 style headers. Parse headers to objects. Most advanced available structure for http headers.

Overview

HTTP Headers, the Complete Toolkit 🧰

Object-oriented headers. Kind of structured headers.
PyPi Publish Action Code style: black Checked with mypy Download Count Total

Why

No matter if you are currently dealing with code using HTTP or IMAP (message, email), you should not worry about easily accessing and exploiting headers.

using kiss-headers from python interpreter

I have seen so many chunks of code trying to deal with these headers; often I saw this implementation:

# No more of that!
charset = headers['Content-Type'].split(';')[-1].split('=')[-1].replace('"', '')

Scroll down and see how you could do it from now on.

🔪 Features

kiss-headers is a basic library that allow you to handle headers as objects.

  • A backwards-compatible syntax using bracket style.
  • Capability to alter headers using simple, human-readable operator notation + and -.
  • Flexibility if headers are from an email or HTTP, use as you need with one library.
  • Ability to parse any object and extract recognized headers from it, it also supports UTF-8 encoded headers.
  • Offer an opinionated way to un/serialize headers.
  • Fully type-annotated.
  • Provide great auto-completion in Python interpreter or any capable IDE.
  • No dependencies. Never will be.
  • 90% test coverage.

Plus all the features that you would expect from handling headers...

  • Properties syntax for headers and attribute in a header.
  • Supports headers and attributes OneToOne, OneToMany and ManySquashedIntoOne.
  • Capable of parsing bytes, fp, str, dict, email.Message, requests.Response, httpx._models.Response and urllib3.HTTPResponse.
  • Automatically unquote and unfold the value of an attribute when retrieving it.
  • Keep headers and attributes ordering.
  • Case-insensitive with header name and attribute key.
  • Character - equal _ in addition of above feature.
  • Any syntax you like, we like.

Installation

Whatever you like, use pipenv or pip, it simply works. Requires Python 3.6+ installed.

pip install kiss-headers --upgrade

🍰 Usage

Quick start

parse_it() method takes bytes, str, fp, dict, email.Message or even a requests.Response or httpx._models.Response itself and returns a Headers object.

from requests import get
from kiss_headers import parse_it

response = get('https://www.google.fr')
headers = parse_it(response)

headers.content_type.charset  # output: ISO-8859-1
# Its the same as
headers["content-type"]["charset"]  # output: ISO-8859-1

Do not forget that headers are not OneToOne. One header can be repeated multiple times and attributes can have multiple values within the same header.

from kiss_headers import parse_it

my_cookies = """set-cookie: 1P_JAR=2020-03-16-21; expires=Wed, 15-Apr-2020 21:27:31 GMT; path=/; domain=.google.fr; Secure; SameSite=none
set-cookie: CONSENT=WP.284b10; expires=Fri, 01-Jan-2038 00:00:00 GMT; path=/; domain=.google.fr"""

headers = parse_it(my_cookies)

type(headers.set_cookie)  # output: list
headers.set_cookie[0].expires # output: Wed, 15-Apr-2020 21:27:31 GMT
headers.set_cookie[0]._1p_jar # output: 2020-03-16-21
headers.set_cookie[0]["1P_JAR"] # output: 2020-03-16-21

Since v2.1 you can transform an Header object to its target CustomHeader subclass to access more methods.

from kiss_headers import parse_it, get_polymorphic, SetCookie

my_cookies = """set-cookie: 1P_JAR=2020-03-16-21; expires=Wed, 15-Apr-2020 21:27:31 GMT; path=/; domain=.google.fr; Secure; SameSite=none
set-cookie: CONSENT=WP.284b10; expires=Fri, 01-Jan-2038 00:00:00 GMT; path=/; domain=.google.fr"""

headers = parse_it(my_cookies)

type(headers.set_cookie[0])  # output: Header

set_cookie = get_polymorphic(headers.set_cookie[0], SetCookie)

type(set_cookie)  # output: SetCookie

set_cookie.get_cookie_name()  # output: 1P_JAR
set_cookie.get_expire()  # output: datetime(...)

Just a note: Accessing a header that has the same name as a reserved keyword must be done this way :

headers = parse_it('From: Ousret; origin=www.github.com\nIS: 1\nWhile: Not-True')

# this flavour
headers.from_ # to access From, just add a single underscore to it
# or.. just using :
headers['from']

✍️ Serialization

Since version 2.3.0 the package offer the possibility to un/serialize Headers.

from requests import get
from kiss_headers import parse_it, dumps

json_repr: str = dumps(
    parse_it(
        get("https://www.google.fr")
    ),
    indent=4
)

print(json_repr)  # See the result bellow

# Additionally, how to parse the JSON repr to Headers again
headers = parse_it(json_repr)  # Yes! that easy!
{
    "Date": [
        {
            "Tue, 02 Feb 2021 21:43:13 GMT": null
        }
    ],
    "Expires": [
        {
            "-1": null
        }
    ],
    "Cache-Control": [
        {
            "private": null
        },
        {
            "max-age": "0"
        }
    ],
    "Content-Type": [
        {
            "text/html": null,
            "charset": "ISO-8859-1"
        }
    ],
    "P3P": [
        {
            "CP": "This is not a P3P policy! See g.co/p3phelp for more info."
        }
    ],
    "Content-Encoding": [
        {
            "gzip": null
        }
    ],
    "Server": [
        {
            "gws": null
        }
    ],
    "X-XSS-Protection": [
        {
            "0": null
        }
    ],
    "X-Frame-Options": [
        {
            "SAMEORIGIN": null
        }
    ],
    "Set-Cookie": [
        {
            "NID": "208=D5XUqjrP9PNpiZu4laa_0xvy_IxBzQLtfxqeAqcPBgiY2y5sfSF51IFuXZnH0zDAF1KZ8x-0VsRyGOM0aStIzCUfdiPBOCxHSxUv39N0vwzku3aI2UkeRXhWw8-HWw5Ob41GB0PZi2coQsPM7ZEQ_fl9PlQ_ld1KrPA",
            "expires": "Wed, 04-Aug-2021 21:43:13 GMT",
            "path": "/",
            "domain": ".google.fr",
            "HttpOnly": null
        },
        {
            "CONSENT": "PENDING+880",
            "expires": "Fri, 01-Jan-2038 00:00:00 GMT",
            "path": "/",
            "domain": ".google.fr"
        }
    ],
    "Alt-Svc": [
        {
            "h3-29": ":443",
            "ma": "2592000"
        },
        {
            "h3-T051": ":443",
            "ma": "2592000"
        },
        {
            "h3-Q050": ":443",
            "ma": "2592000"
        },
        {
            "h3-Q046": ":443",
            "ma": "2592000"
        },
        {
            "h3-Q043": ":443",
            "ma": "2592000"
        },
        {
            "quic": ":443",
            "ma": "2592000",
            "v": "46,43"
        }
    ],
    "Transfer-Encoding": [
        {
            "chunked": null
        }
    ]
}

Alternatively you may use from kiss_headers import parse_it, encode, decode to transform Headers to dict (instead of JSON) or the other way around. Understand that the dict returned in encode will differ from the method to_dict() in Headers.

🛠️ Create headers from objects

Introduced in the version 2.0, kiss-headers now allow you to create headers with more than 40+ ready-to-use, fully documented, header objects.

1st example usage

from kiss_headers import Headers, Authorization
from requests import get

response = get("https://httpbin.org/bearer", headers=Headers(Authorization("Bearer", "qwerty")))
print(response.status_code)  # 200

2nd example usage

from kiss_headers import *

headers = (
    Host("developer.mozilla.org")
    + UserAgent(
        "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0"
    )
    + Accept("text/html")
    + Accept("application/xhtml+xml")
    + Accept("application/xml", qualifier=0.9)
    + Accept(qualifier=0.8)
    + AcceptLanguage("en-US")
    + AcceptLanguage("en", qualifier=0.5)
    + AcceptEncoding("gzip")
    + AcceptEncoding("deflate")
    + AcceptEncoding("br")
    + Referer("https://developer.mozilla.org/testpage.html")
    + Connection(should_keep_alive=True)
    + UpgradeInsecureRequests()
    + IfModifiedSince("Mon, 18 Jul 2016 02:36:04 GMT")
    + IfNoneMatch("c561c68d0ba92bbeb8b0fff2a9199f722e3a621a")
    + CacheControl(max_age=0)
)

raw_headers = str(headers)

raw_headers now retain the following :

Host: developer.mozilla.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:50.0) Gecko/20100101 Firefox/50.0
Accept: text/html, application/xhtml+xml, application/xml; q="0.9", */*; q="0.8"
Accept-Language: en-US, en; q="0.5"
Accept-Encoding: gzip, deflate, br
Referer: https://developer.mozilla.org/testpage.html
Connection: keep-alive
Upgrade-Insecure-Requests: 1
If-Modified-Since: Mon, 18 Jul 2016 02:36:04 GMT
If-None-Match: "c561c68d0ba92bbeb8b0fff2a9199f722e3a621a"
Cache-Control: max-age="0"

See the complete list of available header class in the full documentation. Also, you can create your own custom header object using the class kiss_headers.CustomHeader.

📜 Documentation

See the full documentation for advanced usages : www.kiss-headers.tech

👤 Contributing

Contributions, issues and feature requests are very much welcome.
Feel free to check issues page if you want to contribute.

Firstly, after getting your own local copy, run ./scripts/install to initialize your virtual environment. Then run ./scripts/check before you commit, make sure everything is still working.

Remember to keep it sweet and simple when contributing to this project.

📝 License

Copyright © 2020 Ahmed TAHRI @Ousret.
This project is MIT licensed.

Comments
  • the function is_legal_header_name should not allow any control character (octets 0 - 31) and DEL (127)

    the function is_legal_header_name should not allow any control character (octets 0 - 31) and DEL (127)

    Describe this issue The function is_legal_header_name @ against to the RFC2616 (RFC7230 ?) about CTLs (octets 0 - 31 and DEL 127) and the 19 seprartors (\x2f, \x22) or I am missing any udates of the RFCs.

    ref:

    message-header = field-name ":" [ field-value ]
    field-name     = token
    token          = 1*<any CHAR except CTLs or separators>
    CTL            = <any US-ASCII control character
                            (octets 0 - 31) and DEL (127)>
    separators     = "(" | ")" | "<" | ">" | "@"
                   | "," | ";" | ":" | "\" | <">
                   | "/" | "[" | "]" | "?" | "="
                   | "{" | "}" | SP | HT
    SP             = <US-ASCII SP, space (32)>
    HT             = <US-ASCII HT, horizontal-tab (9)>
    <">            = <US-ASCII double-quote mark (34)>
    

    To Reproduce Steps to reproduce the behavior:

    • Using raw headers

    Expected behavior

    # this should passed
    assert is_legal_header_name('\x00') is False  # NUL
    assert is_legal_header_name('\x07') is False  # BEL
    assert is_legal_header_name('invalid"') is False  # \x22
    assert is_legal_header_name('invalid/') is False  # \x2f
    

    Stacktrace If applicable, add stacktrace to help explain your problem.

    Additional context

    maybe a patch here, if this issue for the `is_legal_header_name` confirmed
    file https://github.com/Ousret/kiss-headers/blob/83775798/kiss_headers/utils.py#L385
    --- a/kiss_headers/utils.py
    +++ b/kiss_headers/utils.py
    - and search(r"[^\x00-\x7F]|[:;(),<>=@?\[\]\r\n\t &{}\\]", name) is None
    + and search(r"[^\x21-\x7e]|[()<>@,;:\x5c\x22\x2f\[\]?={}]", name) is None
    + #                ^^   ^^   ^^^^^^^^   ^   ^   ^ ^ ^^^^^
    + #                --   --   -- ordered 17 separators ---
    
    bug good first issue 
    opened by openalmeida 7
  • [Feature] More precise way to alter/handle attributes within Header

    [Feature] More precise way to alter/handle attributes within Header

    Pull Request

    That PR is not BC-Break. Once merged, this package will be available as version 2.2.0 on PyPi.

    My patch is about

    • [ ] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [x] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [x] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [x] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    In my opinion, what was critically missing from this package is the ability to alter header attributes based on a position. eg. insert this before position 0. This PR brings a new class into models.py called Attributes. Before that, attributes were handled into the Header instance by a structure.CaseInsensibleDict.

    from kiss_headers import Header
    
    if __name__ == "__main__":
    
        header = Header("Content-Type", "text/html; charset=UTF-8; format=flowed; text/html=ALLO")
    
        print(header)  
        # output: 'text/html; charset=UTF-8; format=flowed; text/html=ALLO'
    
        header.insert(1, "hello-world")
    
        print(header)  
        # output: 'text/html; hello-world; charset="UTF-8"; format="flowed"; text/html="ALLO"'
    
        header.insert(5, "zut", qwerty="UTF-47")
        
        print(header)
        # output: 'text/html; hello-world; charset="UTF-8"; format="flowed"; text/html="ALLO"; zut; qwerty="UTF-47"' 
    
    documentation proposal 
    opened by Ousret 2
  • Fixes small typos in README

    Fixes small typos in README

    Pull Request

    My patch is about

    • [ ] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [x] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [ ] Test cases added for changed code if necessary.
    opened by sobolevn 2
  • Creates py.typed file

    Creates py.typed file

    Pull Request

    My patch is about

    • [ ] :bug: Bugfix
    • [x] :arrow_up: Improvement
    • [ ] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [ ] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    I have added py.typed file. It is required to distribute your types with the package. See https://www.python.org/dev/peps/pep-0561/

    Example: https://github.com/dry-python/returns/blob/master/returns/py.typed

    opened by sobolevn 2
  • ✏️Grammar changes to docs

    ✏️Grammar changes to docs

    Saw your post on Dev.to Listings, thought I'd stop by and help edit some docs.

    Changed:

    • verb form usage
    • some phrases to make docs clearer
    • removed excess spaces in some places

    Let me know if this is alright!

    documentation good first issue 
    opened by kewbish 2
  • Release 2.3.1

    Release 2.3.1

    Pull Request

    My patch is about

    • [ ] :bug: Bugfix
    • [x] :arrow_up: Improvement
    • [ ] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [ ] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    Refresh + Add GHA + Explicit 3.11 support

    opened by Ousret 1
  • Release 2.2.4

    Release 2.2.4

    Pull Request

    My patch is about

    • [x] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [ ] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [x] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    Related to #41

    opened by Ousret 1
  • Release 2.2.3

    Release 2.2.3

    Pull Request

    My patch is about

    • [x] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [ ] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature
    • [x] 🔖 Release

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [x] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    • Bugfix: The double-quote character wasn't handled correctly inside attrs value.
    • Bugfix: Cannot pass a BufferedReader (fp) to the parse_it function.
    • Bugfix: Fix the unfolding inside header content.
    bug 
    opened by Ousret 1
  • :bug: Un/escape the double quote char in attrs values

    :bug: Un/escape the double quote char in attrs values

    Pull Request

    My patch is about

    • [x] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [ ] :pencil: Documentation
    • [ ] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [x] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    Close #37

    • Bugfix: The double-quote character wasn't handled correctly inside attributes values.
    from kiss_headers.utils import header_content_split
    from kiss_headers import Attributes
    
    if __name__ == "__main__":
        attributes = Attributes(header_content_split(r'text/html; charset="UTF-\"8"', ";"))
    
        # 1) Retrieve the value
        print(attributes["charset"])   # output: 'UTF-"8'
        # 2) cast to headers str
        print(attributes)  # output: 'text/html; charset="UTF-\"8"'
    
    bug 
    opened by Ousret 1
  • [:bug:] Double quote (escaped) inside attribute value are not handled correctly

    [:bug:] Double quote (escaped) inside attribute value are not handled correctly

    Describe the bug Double quote (escaped) inside attribute value is not handled correctly in a particular case.

    text/html; charset="UTF-\"8"
    

    To Reproduce Steps to reproduce the behavior:

    from kiss_headers.utils import header_content_split
    from kiss_headers import Attributes
    
    if __name__ == "__main__":
        print(
            Attributes(header_content_split('text/html; charset="UTF-\"8"', ";"))
        )
    

    Expected behavior A clear and concise description of what you expected to happen.

    from kiss_headers.utils import header_content_split
    from kiss_headers import Attributes
    
    if __name__ == "__main__":
        attributes = Attributes(header_content_split('text/html; charset="UTF-\"8"', ";"))
    
        # 1) Correct
        print(attributes["charset"])   # output: 'UTF-"8'
        # 2) Wrong
        print(attributes)  # output: 'text/html; charset="UTF-"8"'
        # Should have gotten 'text/html; charset="UTF-\"8"'
    

    https://github.com/Ousret/kiss-headers/blob/master/kiss_headers/models.py#L1211

    bug help wanted 
    opened by Ousret 1
  • Prepare next-minor

    Prepare next-minor

    Pull Request

    My patch is about

    • [x] :bug: Bugfix
    • [ ] :arrow_up: Improvement
    • [x] :pencil: Documentation
    • [x] :heavy_check_mark: Tests
    • [ ] :sparkle: Feature

    Checklist

    • [x] I accept that my PR will be distributed under the MIT license.
    • [x] Test cases added for changed code if necessary.

    Describe what you have changed in this PR.

    • Bugfix: gt and lt implemented but missing ge and le in Header.
    • Bugfix: Attributes.remove() method would fail to remove properly if with_value is None and index is not provided.
    • Bugfix: Support negative index in Attributes.insert() method.
    • Improvement: Docstring additions.
    opened by Ousret 1
  • [:bug:] breaks when using `curl --head` with a proxy

    [:bug:] breaks when using `curl --head` with a proxy

    When a proxy is used, there is an additional HTTP/1.1 200 Connection established\n\n, which this tool can't handle.

    ALL_PROXY=http://127.0.0.1:1087 http_proxy=http://127.0.0.1:1087 https_proxy=http://127.0.0.1:1087 HTTP_PROXY=http://127.0.0.1:1087 HTTPS_PROXY=http://127.0.0.1:1087 curl --head https://ipython.readthedocs.io/_/downloads/en/stable/epub/                               
    
    HTTP/1.1 200 Connection established
    
    HTTP/2 200 
    date: Tue, 28 Sep 2021 13:45:34 GMT
    content-type: application/epub+zip
    content-length: 3706401
    content-disposition: filename=ipython-readthedocs-io-en-stable.epub
    x-amz-id-2: 2PO2WHP4qGqkhyC1VbRE2KLN2g4uk38vYzaNJDU/OBSxh4lUtYgERD2FNAOPkKPD1a6rsNBMeKI=
    x-amz-request-id: 21E21R71FAY4WQKT
    last-modified: Sat, 25 Sep 2021 00:43:37 GMT
    etag: "6f512f04591f7667486d044c54708448"
    x-served: Nginx-Proxito-Sendfile
    x-backend: web-i-078619706c1392c2c
    x-rtd-project: ipython
    x-rtd-version: stable
    x-rtd-path: /proxito/epub/ipython/stable/ipython.epub
    x-rtd-domain: ipython.readthedocs.io
    x-rtd-version-method: path
    x-rtd-project-method: subdomain
    referrer-policy: no-referrer-when-downgrade
    permissions-policy: interest-cohort=()
    strict-transport-security: max-age=31536000; includeSubDomains; preload
    cf-cache-status: HIT
    age: 270
    expires: Tue, 28 Sep 2021 15:45:34 GMT
    cache-control: public, max-age=7200
    accept-ranges: bytes
    expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
    server: cloudflare
    cf-ray: 695d69b549330686-LHR
    
    bug 
    opened by NightMachinery 1
Releases(2.3.1)
  • 2.3.1(Apr 16, 2022)

  • 2.3.0(Feb 2, 2021)

    Changes :

    • Feature: Offer an opinionated way to un/serialize headers #45
    • Bugfix: Fix inserting attribute in header using index when header is empty ad546fe31d2f79e28f86cadec2fef35b5679bbb1
    • Miscellaneous: Add python 3.10 to supported interpreters
    Source code(tar.gz)
    Source code(zip)
  • 2.2.4(Jan 27, 2021)

    Changes :

    • Bugfix: Function is_legal_header_name approved some illegal header name. #41
    • Miscelaneous: Added MANIFEST.in file
    • Other: Method values() of the class Headers was returning NotImplemented, now raise NotImplementedError instead.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.3(May 28, 2020)

    Changes:

    • Bugfix: The double-quote character wasn't handled correctly inside an attrs value.
    • Bugfix: Cannot pass a BufferedReader (fp) to the parse_it function.
    • Bugfix: Fix the unfolding inside header content.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.2(May 24, 2020)

    Changes: This is a bugfix release. (#36)

    • Bugfix: gt and lt implemented but missing ge and le in Header.
    • Bugfix: Attributes.remove() method would fail to remove properly if with_value is None and index is not provided.
    • Bugfix: Support negative index in Attributes.insert() method.
    • Bugfix: Delete an attribute no longer remove members that are named after the target key. #35
    • Improvement: Docstring additions.
    Source code(tar.gz)
    Source code(zip)
  • 2.2.1(May 21, 2020)

  • 2.2.0(May 20, 2020)

    Changes:

    • Improvement: Implement insert() method on Headers class.
    • Feature: Introducing the Attributes class in models. Attributes/members are now ordered by default.
    • Improvement: Add pop() and insert() methods on Header class.
    • Bugfix: Unescape the double quote char in the cookie value when using SetCokies or Cookie classes.
    • Improvement: Implement valued_attrs property on Header to extract a list of distinct attributes that have at least one value attached to them.

    The biggest improvement is that the Header class now acts ordered on its members and attributes/keys/values. See PR #32

    The package will most likely go into feature freeze until 3.0-dev. The current focus will be around tests/docs and issues addressed. Enjoy 🎉 Thank all present and future adopters.

    Docs are going to be updated soon.

    Source code(tar.gz)
    Source code(zip)
  • 2.1.2(May 14, 2020)

    Changes:

    • Bugfix: dir method in Header instance could contain entries with illegal characters.
    • Documentation: Major update available at kiss-headers.tech
    • Bugfix: Allow set item value to contain comma-separated entries in Headers.
    • Bugfix: pop() method on Headers was discarding output_lock_type() toggle.
    • Feature: Introducing index() method on Headers class. Behave like list().index().
    • Bugfix: ContentDisposition was rejecting perfectly valid non-ASCII filename.
    • Improvement: Add ready-to-use methods in ContentDisposition class.
    • Improvement: Creates py.typed file. #29
    • Others: Docstring improvements.
    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(May 11, 2020)

    Changes :

    • Bugfix: Disallow single colon in username when using BasicAuth.
    • Add: Create ContentSecurityPolicy custom header in builder.py.
    • Improvement: Add ready-to-use methods in Authorization, BasicAuthorization, AltSvc, StrictTransportSecurity, ContentSecurityPolicy, WwwAuthenticate and ContentRange.
    • Improvement: Adjust/Add get_qualifier() method when needed in builder.py.
    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(May 5, 2020)

    Changes :

    • Feature : Polymorphism, transform a Header object to its corresponding subclass. #26
    • Feature : Implement pop() and popitem() methods in Headers.
    • Bugfix : Discard multiple entries detection if the header is 'Subject'.
    • Bugfix : Acknowledge the folding LF + 1 space technique to unfold.
    • Add : Cookie custom header class in builder.py.
    • Bugfix : Fix how WwwAuthenticate custom header is built.
    • Feature: Add unfolded_content property to Header class.
    • Other : Provide scripts for developers. #24
    Source code(tar.gz)
    Source code(zip)
  • 2.0.5(Apr 19, 2020)

    Changes : #22 #21 #20

    • Feature : Retrieve comments in header content using newly created comments property on Header.
    • Feature : Parse headers that are UTF-8 encoded when using parse_it() function with bytes.
    • Feature : Attribute value in header are unfolded by default when retrieving it. content property is not altered.
    • Other : Minor code simplification in Header class. Remove redundant private member.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.4(Apr 17, 2020)

    Changes :

    • Feature : Add method has_many() to verify if an header or attribute name has multiple entries associated.
    • Improvement : Allow class that inherit from CustomHeader to override their header name.
    • Feature : Add BasicAuthorization in the ready-to-use headers objects.
    • Bugfix : Implement bool method for Headers class to act like list() does.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Apr 16, 2020)

    Changes :

    • Bugfix : Better detection of an illegal header name.
    • Improvement : parse_it() was too permissive and allowed illegal header name to be included.
    • Feature : Reversed can now be called upon an Headers instance.
    • Feature : Sorted can be used with an Headers instance to return a list of Header in alphabetical order.
    • Bugfix : ContentDisposition custom class was not encoding fallback filename properly.
    • Improvement : Headers class can be instantiated like Headers(Header("Content-Type", "text/html"), Header("Allow", "POST")).
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Apr 12, 2020)

    Changes :

    • Bugfix : Support for (yet unreleased) Python 3.9
    • Other : Disallow illegal header name when using Header class.

    Also a few improvements in the code struct. 👍

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Apr 11, 2020)

    This is a minor release, ship bugfixes.

    Changes :

    • Bugfix : Using CR+LF instead of LF when using repr of Headers #13
    • Bugfix : Removing member from an Header may left trailing spaces or a unneeded coma #15
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Apr 9, 2020)

    Changes : PR #11

    • Bugfix : Prevent add a semicolon if this is the first entry when doing header+="preload" # "; preload".
    • Feature : Implement the possibility to invoke '+' and '-' operator on Header and string.
    • Feature : Introducing the builder. 40+ ready-to-use classes fully documented to create on-the-fly headers.
    • Improvement : The structure of the package has been changed.
    • Feature : Support email.Message object in the parse_it() function.
    • Feature : Support for parsing urllib3.HTTPResponse in parse_it()
    • Minor : Add Alt_Svc header hint on Headers class for autocompletion in IDEs.
    • Feature/Improvement : Introduce the capability of detecting multiple entries in content for a single header.
    • Bugfix : Header names were not kept in order when using keys() method of Headers object.
    • Bugfix : Cmp header to another header object is now expected to behave correctly.
    • Feature : Introduce explain() function that take an Headers object and output a dict containing explanation, if available, of each entry.
    • Bugfix : eq method of Headers and Header classes should raise the proper exception now. NotImplementedError instead of NotImplemented eg. not callable.
    • Bugfix : Properly unquote member(s) of an Header object.

    Docs are on their way 👍

    Source code(tar.gz)
    Source code(zip)
  • 1.1.1(Mar 28, 2020)

    Changes : from PR #10

    • Feature : You can parse Response from encode/httpx package. Just use parse_it() method.
    • Feature : Possibility to generate a JSON-string from a Headers object using to_json() method.
    • Feature : Embed the capability to cast any header and Headers to bytes.
    • Improvement : We've successfully passed mypy type-lint check.
    • Feature : Allow to lock type output to List of Header instead of second guessing if List or a Header using lock_output_type() method from kiss-headers package init.
    • Bugfix : Automatically cast object to str if trying to assign to Header anything else than str.

    Thank to @kewbish for grammar changes to docs in PR #9

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Mar 22, 2020)

    Changes :

    • Improvement : No more dependencies required.
    • Style : We embrace the black code style.
    • Feature : Add method items() to Headers.
    • Bugfix : Fetch attribute from Header even if key is named after a reserved keyword or start with digit.
    • Feature : Add the possibility to assign attribute of an Header using property notation or using bracket style (#8).

    Full documentation is available at www.kiss-headers.tech and it is still work in progress. But it is enough to get started properly.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Mar 20, 2020)

    Changes : PR #5

    • Bugfix : Check if provided raw bytes headers are encoded using ASCII or UTF-8.
    • Bugfix : Provide a better output using case insensible dict for the to_dict method.
    • Improvement : Act like a regular dict as is act like an object.
    • Improvement : Writing missing docstring for public package and for all methods of Headers and Header.
    • Type-hint : Adding From header type hint on Headers class.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Mar 18, 2020)

    Changes : PR #4

    • Bugfix : Accessing header that are named the same as a reserved python keyword. From: eg
    • Feature : Possibility to invoke deep copy on Headers and Header objects.
    • Feature : Subtract header from Headers by name (string) or object using operator -
    • Feature : Add header object to headers using operator +

    Thank to all early adopters !

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Mar 16, 2020)

    Changes :

    • Support : Add samesite and domain hint for Header class
    • Bugfix : Should not allow key/attribute to have space in it
    • Bugfix : Parse headers even if first n line(s) are not headers
    • Feature : Support natively responses from Requests and extract headers properly
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Mar 16, 2020)

  • 1.0.0(Mar 15, 2020)

Aiosonic - lightweight Python asyncio http client

aiosonic - lightweight Python asyncio http client Very fast, lightweight Python asyncio http client Here is some documentation. There is a performance

Johanderson Mogollon 93 Jan 06, 2023
A modern/fast python SOAP client based on lxml / requests

Zeep: Python SOAP client A fast and modern Python SOAP client Highlights: Compatible with Python 3.6, 3.7, 3.8 and PyPy Build on top of lxml and reque

Michael van Tellingen 1.7k Jan 01, 2023
HTTP Request & Response Service, written in Python + Flask.

httpbin(1): HTTP Request & Response Service

Postman Inc. 11.3k Jan 01, 2023
Python Simple SOAP Library

PySimpleSOAP / soap2py Python simple and lightweight SOAP library for client and server webservices interfaces, aimed to be as small and easy as possi

PySimpleSOAP 369 Jan 02, 2023
suite de mocks http em json

Ritchie Formula Repo Documentation Contribute to the Ritchie community This repository contains rit formulas which can be executed by the ritchie-cli.

Kaio Fábio Prates Prudêncio 1 Nov 01, 2021
An interactive command-line HTTP and API testing client built on top of HTTPie featuring autocomplete, syntax highlighting, and more. https://twitter.com/httpie

HTTP Prompt HTTP Prompt is an interactive command-line HTTP client featuring autocomplete and syntax highlighting, built on HTTPie and prompt_toolkit.

HTTPie 8.6k Dec 31, 2022
Pretty fast mass-dmer with multiple tokens support made with python requests

mass-dm-requests - Little preview of the Logger and the Spammer Features Logging User IDS Sending DMs (Embeds are supported) to the logged IDs Includi

karma.meme 14 Nov 18, 2022
EasyRequests is a minimalistic HTTP-Request Library that wraps aiohttp and asyncio in a small package that allows for sequential, parallel or even single requests

EasyRequests EasyRequests is a minimalistic HTTP-Request Library that wraps aiohttp and asyncio in a small package that allows for sequential, paralle

Avi 1 Jan 27, 2022
Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once

pathprober Probe and discover HTTP pathname using brute-force methodology and filtered by specific word or 2 words at once. Purpose Brute-forcing webs

NFA 41 Jul 06, 2022
A Python obfuscator using HTTP Requests and Hastebin.

🔨 Jawbreaker 🔨 Jawbreaker is a Python obfuscator written in Python3, using double encoding in base16, base32, base64, HTTP requests and a Hastebin-l

Billy 50 Sep 28, 2022
Asynchronous Python HTTP Requests for Humans using Futures

Asynchronous Python HTTP Requests for Humans Small add-on for the python requests http library. Makes use of python 3.2's concurrent.futures or the ba

Ross McFarland 2k Dec 30, 2022
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie

HTTPie: human-friendly CLI HTTP client for the API era HTTPie (pronounced aitch-tee-tee-pie) is a command-line HTTP client. Its goal is to make CLI in

HTTPie 25.4k Jan 01, 2023
HTTP Request Smuggling Detection Tool

HTTP Request Smuggling Detection Tool HTTP request smuggling is a high severity vulnerability which is a technique where an attacker smuggles an ambig

Anshuman Pattnaik 282 Jan 03, 2023
Single-file replacement for python-requests

mureq mureq is a single-file, zero-dependency replacement for python-requests, intended to be vendored in-tree by Linux systems software and other lig

Shivaram Lingamneni 267 Dec 28, 2022
A simple, yet elegant HTTP library.

Requests Requests is a simple, yet elegant HTTP library. import requests r = requests.get('https://api.github.com/user', auth=('user', 'pass')

Python Software Foundation 48.8k Jan 05, 2023
A next generation HTTP client for Python. 🦋

HTTPX - A next-generation HTTP client for Python. HTTPX is a fully featured HTTP client for Python 3, which provides sync and async APIs, and support

Encode 9.8k Jan 05, 2023
r - a small subset of Python Requests

r a small subset of Python Requests a few years ago, when I was first learning Python and looking for http functionality, i found the batteries-includ

Gabriel Sroka 4 Dec 15, 2022
💡Python package for HTTP/1.1 style headers. Parse headers to objects. Most advanced available structure for http headers.

HTTP Headers, the Complete Toolkit 🧰 Object-oriented headers. Kind of structured headers. ❓ Why No matter if you are currently dealing with code usin

TAHRI Ahmed R. 103 Dec 02, 2022
A minimal HTTP client. ⚙️

HTTP Core Do one thing, and do it well. The HTTP Core package provides a minimal low-level HTTP client, which does one thing only. Sending HTTP reques

Encode 306 Dec 27, 2022
Python HTTP library with thread-safe connection pooling, file post support, user friendly, and more.

urllib3 is a powerful, user-friendly HTTP client for Python. Much of the Python ecosystem already uses urllib3 and you should too. urllib3 brings many

urllib3 3.2k Dec 29, 2022