Fetch url and create a response object according to the mime-type.

        Args:
            url: The url to fetch data from

        Returns:
            OEmbedResponse object according to data fetched

def fetch(self, url):
        '''
        Fetch url and create a response object according to the mime-type.

        Args:
            url: The url to fetch data from

        Returns:
            OEmbedResponse object according to data fetched
        '''
        opener = self._urllib.build_opener()
        opener.addheaders = self._requestHeaders.items()
        response = opener.open(url)
        headers = response.info()
        raw = response.read()
        raw = raw.decode('utf8')

        if not 'Content-Type' in headers:
            raise OEmbedError('Missing mime-type in response')

        if headers['Content-Type'].find('application/xml') != -1 or \
           headers['Content-Type'].find('text/xml') != -1:
            response = OEmbedResponse.newFromXML(raw)
        elif headers['Content-Type'].find('application/json') != -1 or \
             headers['Content-Type'].find('text/javascript') != -1 or \
             headers['Content-Type'].find('text/json') != -1:
            response = OEmbedResponse.newFromJSON(raw)
        else:
            raise OEmbedError('Invalid mime-type in response - %s' % headers['Content-Type'])

        return response