Skip to content

Commit

Permalink
MYFACES-3543 java.lang.IllegalArgumentException: text/xml on ajax req…
Browse files Browse the repository at this point in the history
…uests with webkit mobile browser
  • Loading branch information
Leonardo Uribe committed May 31, 2012
1 parent b65184e commit 9d5d20e
Showing 1 changed file with 30 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,40 @@ public ResponseWriter createResponseWriter(Writer writer, String contentTypeList
}
}

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);
}
}
}
}
Expand Down

0 comments on commit 9d5d20e

Please sign in to comment.