Fixing bug in HTTP accept header processing as requested by timbl@w3.org

This commit is contained in:
bdc34 2010-05-11 13:50:33 +00:00
parent da6ac0eef1
commit a8cfc10b2e
3 changed files with 26 additions and 2 deletions

View file

@ -423,7 +423,7 @@ public class EntityController extends VitroHttpServlet {
* @return null if this is not a linked data request, returns content type if it is a * @return null if this is not a linked data request, returns content type if it is a
* linked data request. * linked data request.
*/ */
private ContentType checkForLinkedDataRequest(String url, String acceptHeader) { protected ContentType checkForLinkedDataRequest(String url, String acceptHeader) {
try { try {
//check the accept header //check the accept header
if (acceptHeader != null) { if (acceptHeader != null) {

View file

@ -260,7 +260,7 @@ public class ContentType implements Serializable {
if (qValue <= 0 || qValue > 1) { if (qValue <= 0 || qValue > 1) {
continue; continue;
} }
curQ = qValue; curQ = qValue + 0.0001F;
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
// ignore exception // ignore exception

View file

@ -0,0 +1,24 @@
package edu.cornell.mannlib.vitro.webapp.controller;
import org.junit.Assert;
import org.junit.Test;
import edu.cornell.mannlib.vitro.webapp.web.ContentType;
public class EntityControllerTest {
@Test
public void testAcceptHeader(){
EntityController entityController = new EntityController();
/* Check to see if vitro would send RDF/XML to tabulator */
String tabulatorsAcceptHeader =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.5,text/plain;q=0.5," +
"image/png,*/*;q=0.1," +
"application/rdf+xml;q=1.0,text/n3;q=0.4";
ContentType result = entityController.checkForLinkedDataRequest("http://notUsedInThisTestCase.com/bogus",tabulatorsAcceptHeader);
Assert.assertTrue( result != null );
Assert.assertTrue( "application/rdf+xml".equals( result.toString()) );
}
}