Last active
June 14, 2018 06:30
-
-
Save mdornseif/2892d16f80438fc19c107dcf306daecf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-------> | |
[] | |
'Content-Type' 'image/png' | |
'Content-Length' '89142' | |
'X-AppEngine-Upload-Creation' '2018-06-13 23:05:52.565812' | |
'X-AppEngine-Cloud-Storage-Object' '/gs/eap-dokumente/-/common/dokumente/L2Fw=' | |
-------> 8bit | |
[] | |
'Content-Type' 'image/png' | |
'Content-Length' '89142' | |
'X-AppEngine-Upload-Creation' '2018-06-13 23:05:52.565812' | |
'X-AppEngine-Cloud-Storage-Object' '/gs/eap-dokumente/-/common/dokumente/L2Fw=' | |
-------> 7bit | |
[] | |
'Content-Type' 'image/png' | |
'Content-Length' '89142' | |
'X-AppEngine-Upload-Creation' '2018-06-13 23:05:52.565812' | |
'X-AppEngine-Cloud-Storage-Object' '/gs/eap-dokumente/-/common/dokumente/L2Fw=' | |
-------> binary | |
[] | |
'Content-Type' 'image/png' | |
'Content-Length' '89142' | |
'X-AppEngine-Upload-Creation' '2018-06-13 23:05:52.565812' | |
'X-AppEngine-Cloud-Storage-Object' '/gs/eap-dokumente/-/common/dokumente/L2Fw=' | |
-------> quoted-printable | |
[] | |
'Content-Type' 'image/png' | |
'Content-Length' '89142' | |
'X-AppEngine-Upload-Creation' '2018-06-13 23:05:52.565812' | |
'X-AppEngine-Cloud-Storage-Object' '/gs/eap-dokumente/-/common/dokumente/L2FwcGhvc3RpbmdfZ2xvYmFsL2Jsb2JzL0FFbkIyVXBoTDg3TzhjLUdfOWpISk5VMGJmbER6VGJJdXZOcGxwS2g4STBtTEgtQzBEazJGSU5iSVk4Z1JSckc3TVhZVjVtcXpua2FuUUVTM2pva1R4MWtycVFuTTN2R213LnExRFUxd045RWZpWkdoSlU' | |
'Content-MD5' 'NjVlNWE4NGRhNTY4YTRjNWQyZmZjOTY4YTkzNzA3MjU=' | |
'Content-Disposition' 'form-data; name=f; \r\n\tfilename="1EC81BF811517A50385D59B9DD05F1BABBF8C7CB446AC99EFBC3FC7CBB2BA1D1.png"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = 'Content-Type: image/png\r\nContent-Length: 89142\r\nX-AppEngine-Upload-Creation: 2018-06-13 23:05:52.565812\r\nX-AppEngine-Cloud-Storage-Object: /gs/eap-dokumente/-/common/dokumente/L2Fw=\r\ncGhvc3RpbmdfZ2xvYmFsL2Jsb2JzL0FFbkIyVXBoTDg3TzhjLUdfOWpISk5VMGJmbER6VGJJdXZ=\r\nOcGxwS2g4STBtTEgtQzBEazJGSU5iSVk4Z1JSckc3TVhZVjVtcXpua2FuUUVTM2pva1R4MWtycV=\r\nFuTTN2R213LnExRFUxd045RWZpWkdoSlU\r\nContent-MD5: NjVlNWE4NGRhNTY4YTRjNWQyZmZjOTY4YTkzNzA3MjU=3D\r\nContent-Disposition: form-data; name=3Df;=20\r\n\tfilename=3D"1EC81BF811517A50385D59B9DD05F1BABBF8C7CB446AC99EFBC3FC7CBB2BA1=\r\nD1.png"\r\n\r\n' | |
import email.message | |
def parse(encoding): | |
message = email.message.Message() | |
message.add_header('content-transfer-encoding', encoding) | |
# Content-Transfer-Encoding | |
message.set_payload(data) | |
payload = message.get_payload(decode=True) | |
return email.message_from_string(payload) | |
for coding in ['', '8bit', '7bit', 'binary', 'quoted-printable']: | |
print "\n\n ------->", coding | |
msg = parse(coding) | |
print msg.defects | |
for k, v in msg.items(): | |
print repr(k), repr(v) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment