You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2012/05/31 16:03:44 UTC
svn commit: r1344729 -
/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
Author: lu4242
Date: Thu May 31 14:03:44 2012
New Revision: 1344729
URL: http://svn.apache.org/viewvc?rev=1344729&view=rev
Log:
MYFACES-3543 java.lang.IllegalArgumentException: text/xml on ajax requests with webkit mobile browser
Modified:
myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
Modified: myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java?rev=1344729&r1=1344728&r2=1344729&view=diff
==============================================================================
--- myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java (original)
+++ myfaces/core/branches/2.0.x/impl/src/main/java/org/apache/myfaces/renderkit/html/HtmlRenderKitImpl.java Thu May 31 14:03:44 2012
@@ -284,22 +284,40 @@ public class HtmlRenderKitImpl extends R
}
}
- if (selectedContentType == null && contentTypeListStringFromAccept != null)
+ if (selectedContentType == null)
{
- String[] contentTypes = ContentTypeUtils.splitContentTypeListString(
- contentTypeListStringFromAccept);
- if (ContentTypeUtils.containsContentType(ContentTypeUtils.ANY_CONTENT_TYPE, contentTypes))
+ if (contentTypeListStringFromAccept != null)
+ {
+ String[] contentTypes = ContentTypeUtils.splitContentTypeListString(
+ contentTypeListStringFromAccept);
+ if (ContentTypeUtils.containsContentType(ContentTypeUtils.ANY_CONTENT_TYPE, contentTypes))
+ {
+ selectedContentType = myfacesConfig.getDefaultResponseWriterContentTypeMode();
+ }
+ }
+ else if (isAjaxRequest)
{
+ // If is an ajax request, contentTypeListStringFromAccept == null and
+ // contentTypeListString != null, contentTypeListString should not be taken
+ // into account, because the final content type in this case is for PartialResponseWriter
+ // implementation. In this case rfc2616-sec14 takes precedence:
+ //
+ // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+ // 14.1 Accept
+ // If no Accept header field is present, then it is assumed that the client
+ // accepts all media types.
selectedContentType = myfacesConfig.getDefaultResponseWriterContentTypeMode();
}
- }
-
- if (selectedContentType == null)
- {
- throw new IllegalArgumentException(
- "ContentTypeList does not contain a supported content type: "
- + contentTypeListString != null ?
- contentTypeListString : contentTypeListStringFromAccept);
+ if (selectedContentType == null)
+ {
+ // Note this case falls when contentTypeListStringFromAccept == null and
+ // contentTypeListString != null, but since this not an ajax request,
+ // contentTypeListString should be taken strictly and throw IllegalArgumentException
+ throw new IllegalArgumentException(
+ "ContentTypeList does not contain a supported content type: "
+ + contentTypeListString != null ?
+ contentTypeListString : contentTypeListStringFromAccept);
+ }
}
}
}