697 def ie_browser(self): |
697 def ie_browser(self): |
698 useragent = self.useragent() |
698 useragent = self.useragent() |
699 return useragent and 'MSIE' in useragent |
699 return useragent and 'MSIE' in useragent |
700 |
700 |
701 def xhtml_browser(self): |
701 def xhtml_browser(self): |
|
702 """return True if the browser is considered as xhtml compatible. |
|
703 |
|
704 If the instance is configured to always return text/html and not |
|
705 application/xhtml+xml, this method will always return False, even though |
|
706 this is semantically different |
|
707 """ |
|
708 if self.vreg.config['force-html-content-type']: |
|
709 return False |
702 useragent = self.useragent() |
710 useragent = self.useragent() |
703 # * MSIE/Konqueror does not support xml content-type |
711 # * MSIE/Konqueror does not support xml content-type |
704 # * Opera supports xhtml and handles namespaces properly but it breaks |
712 # * Opera supports xhtml and handles namespaces properly but it breaks |
705 # jQuery.attr() |
713 # jQuery.attr() |
706 if useragent and ('MSIE' in useragent or 'KHTML' in useragent |
714 if useragent and ('MSIE' in useragent or 'KHTML' in useragent |
707 or 'Opera' in useragent): |
715 or 'Opera' in useragent): |
708 return False |
716 return False |
709 return True |
717 return True |
710 |
718 |
711 def html_content_type(self): |
719 def html_content_type(self): |
712 if not self.vreg.config['force-html-content-type'] and self.xhtml_browser(): |
720 if self.xhtml_browser(): |
713 return 'application/xhtml+xml' |
721 return 'application/xhtml+xml' |
714 return 'text/html' |
722 return 'text/html' |
715 |
723 |
716 from cubicweb import set_log_methods |
724 from cubicweb import set_log_methods |
717 set_log_methods(CubicWebRequestBase, LOGGER) |
725 set_log_methods(CubicWebRequestBase, LOGGER) |