First thing, thanks for this code it is a big help. One issue I ran into was this line. When the Content-type has the optional parameter value (in my case the character encoding) the content-type check fails. See [RFC-1341](http://www.w3.org/Protocols/rfc1341/4_Content-Type.html). I am using `.split(";")[0]` and it is working for my use cases.