def get_content_type ( headers ) : ptype = headers . get ( 'Content-Type' , 'application/octet-stream' ) if ";" in ptype : # split off not needed extension info ptype = ptype . split ( ';' ) [ 0 ] return ptype . strip ( ) . lower ( )
python get post content type
Get the MIME type from the Content - Type header value or application / octet - stream if not found .
def get_content_type (headers):
    """
    Get the MIME type from the Content-Type header value, or
    'application/octet-stream' if not found.

    @return: MIME type
    @rtype: string
    """
    ptype = headers.get('Content-Type', 'application/octet-stream')
    if ";" in ptype:
        # split off not needed extension info
        ptype = ptype.split(';')[0]
    return ptype.strip().lower()