if ( ! request.hasAccept() ) {
//return the image
return false;
} else {
// The browser has given some preferences:
HttpAccept accepts[] = request.getAccept() ;
//two content types image/jpeg and comment-type
HttpAccept imgAccept =
getMatchingAccept(accepts, getContentType());
HttpAccept comAccept =
getMatchingAccept(accepts, getCommentType());
if ((imgAccept != null) && (comAccept != null)) {
// go for best MIME match first
int matchImg = getContentType().match(imgAccept.getMimeType());
int matchCom = getCommentType().match(comAccept.getMimeType());
if (matchImg == matchCom) {
// equals, use quality
return (imgAccept.getQuality() < comAccept.getQuality());
} else {
return (matchImg < matchCom);
}
} else if (comAccept != null)
return true;