I'm thrilled to share with the community ´kiss-headers´. "Keep It Simple, Stupid, Headers". This idea came from the fact that I have seen so much chunk of code trying to deal with headers, often I saw this :
charset = headers['Content-Type'].split(';')[-1].split('=')[-1].replace('"', '') *No more of that !* 🤮
No matter your religion, IMAP4 or HTTP, you should not worry about accessing easily header and associated attributes, adjectives or values. Even ´psf/requests ́ represent headers with a dictionary and that is not representative of what headers are. They are not 1 to 1. And accessing 'Content_type' should work as well as 'Content-Type'.
This package is capable of extracting original headers, unmodified and exploitable from a Response object of requests or bytes, fp or str. It is working on both HTTP and IMAP headers.
So that is why I decided to expose a sweet way to access them, based on the most common needs o f the community. The license is MIT !
Take a glimpse at it : https://github.com/Ousret/kiss-headers
Hope you like it !