def extractBoundary(headers):
        regexp = 'boundary=(.*)'

        if 'Content-Type' in headers:
            contentType = headers['Content-Type']
        else:
            contentType = headers['content-type']

        match = re.search(regexp,contentType)

        if match == None:
            raise Exception('Could not find a multipart message boundary')

        else:
            return match.group(1)