No matters your religion, IMAP4 or HTTP, you should not worries about accessing easily header and associated attributes, adjectives or values.
🚀 Headers: Keep-It=Simple; And=Stupid; With=Auto-Completion. Support HTTP, IMAP. 🍦 Any flavour. alternatives and similar packages
Based on the "HTTP" category
HTTP Requests for Humans™.
requests + gevent for asynchronous HTTP requests.
A HTTP library with thread-safe connection pooling, file post support, sanity friendly.
Asynchronous Python HTTP Requests for Humans using Futures
Jasmin - Open source SMS gateway
Comprehensive HTTP client library.
A Declarative HTTP Client for Python
Python requests like API built on top of Twisted's HTTP client.
Python API client generator
Asynchronous Python HTTP Requests for Humans using twisted
Code any API wrappers with ease and in pythonic way.
Bearer API client for Python
Doublify API toolkit for Python
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of 🚀 Headers: Keep-It=Simple; And=Stupid; With=Auto-Completion. Support HTTP, IMAP. 🍦 Any flavour. or a related project?
Welcome to Headers for Humans 👋
Combine advantages of many representations, with auto-completion!
No matter if you are currently building software using HTTP or IMAP, you should not worry about easily accessing header and associated attributes, adjectives or values.
I have seen so many chunks of code trying to deal with these headers; often I saw this implementation :
charset = headers['Content-Type'].split(';')[-1].split('=')[-1].replace('"', '')
No more of that !
kiss-headers is a basic library that allow you to handle headers with great care.
- A backwards-compatible syntax using bracket style.
- Capability to alter headers using simple, human-readable operator notation
- Flexibility if headers are from IMAP4 or HTTP, use as you need with one library.
- Ability to parse any object and extract recognized headers from it.
- Fully type-annotated.
- Provide great auto-completion in Python interpreter or any capable IDE.
- 90% test coverage.
Plus all the features that you would expect from handling headers...
- Properties syntax for headers and attribute in header.
- Supports headers and attributes OneToOne and OneToMany.
- Capable of parsing
- Automatically unquote value of an attribute when retrieving it.
- Case insensitive with header name and attribute key.
_in addition of above feature.
- Any syntax you like, we like.
Whatever you like, use
pip, it simply works. Requires Python 3.6+ installed.
pip install kiss-headers
parse_it() method takes
dict or even
httpx._models.Response itself and returns a
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
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.expires # output Wed, 15-Apr-2020 21:27:31 GMT
If this behaviour does bother you, you can lock output to always be a list. Just call
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.. headers['from']
See the full documentation for advanced usages : www.kiss-headers.tech
Contributions, issues and feature requests are very much welcome. Feel free to check issues page if you want to contribute.
*Note that all licence references and agreements mentioned in the 🚀 Headers: Keep-It=Simple; And=Stupid; With=Auto-Completion. Support HTTP, IMAP. 🍦 Any flavour. README section above are relevant to that project's source code only.