'Sets the headers and also analyzes them in order to get the response
mime type (text/html , application/pdf, etc).
:param headers: The headers dict.'

def set_headers(self, headers):

    if isinstance(headers, httplib.HTTPMessage):
        self._headers = Headers()
        for header in headers.headers:
            (key, value) = header.split(':', 1)
            self._headers[key.strip()] = value.strip()
    else:
        self._headers = headers
    find_word = (lambda w: (content_type.find(w) != (-1)))
    (content_type_hvalue, _) = self._headers.iget(CONTENT_TYPE, None)
    if (content_type_hvalue is not None):
        try:
            self._content_type = content_type_hvalue.split(';', 1)[0].strip().lower()
        except:
            msg = 'Invalid    Content-Type    value    "%s"    sent    in    HTTP    response.'
            om.out.debug((msg % (content_type_hvalue,)))
        else:
            content_type = self._content_type
            if content_type.count('image'):
                self._doc_type = HTTPResponse.DOC_TYPE_IMAGE
            elif content_type.count('pdf'):
                self._doc_type = HTTPResponse.DOC_TYPE_PDF
            elif content_type.count('x-shockwave-flash'):
                self._doc_type = HTTPResponse.DOC_TYPE_SWF
            elif any(imap(find_word, ('text', 'html', 'xml', 'txt', 'javascript'))):
                self._doc_type = HTTPResponse.DOC_TYPE_TEXT_OR_HTML
    if (self._doc_type is None):
        self._doc_type = HTTPResponse.DOC_TYPE_OTHER
