play1
play1 copied to clipboard
Http Request resolveFormat function
Hi,I find an issue in play1.2.7.the code is located at play.mvc.Http.java`s inner class Request. the commnet says order is not same as the function resolveFormat it work. Mybe the 5th and 6th if statement should exchange
`/** * Automatically resolve request format from the Accept header * (in this order : html > xml > json > text) */ public void resolveFormat() {
if (format != null) {
return;
}
if (headers.get("accept") == null) {
format = "html".intern();
return;
}
String accept = headers.get("accept").value();
if (accept.indexOf("application/xhtml") != -1 || accept.indexOf("text/html") != -1 || accept.startsWith("*/*")) {
format = "html".intern();
return;
}
if (accept.indexOf("application/xml") != -1 || accept.indexOf("text/xml") != -1) {
format = "xml".intern();
return;
}
if (accept.indexOf("text/plain") != -1) {
format = "txt".intern();
return;
}
if (accept.indexOf("application/json") != -1 || accept.indexOf("text/javascript") != -1) {
format = "json".intern();
return;
}
if (accept.endsWith("*/*")) {
format = "html".intern();
return;
}
}`