You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by sc...@apache.org on 2011/11/06 01:47:07 UTC

svn commit: r1198117 - in /incubator/wookie/trunk: src-tests/org/apache/wookie/tests/functional/ src/org/apache/wookie/controller/

Author: scottbw
Date: Sun Nov  6 00:47:07 2011
New Revision: 1198117

URL: http://svn.apache.org/viewvc?rev=1198117&view=rev
Log:
Use Accept header to negotiate API content (see WOOKIE-286)

Modified:
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WhiteListControllerTest.java
    incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetAccessRequestPolicyControllerTest.java
    incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java

Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WhiteListControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WhiteListControllerTest.java?rev=1198117&r1=1198116&r2=1198117&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WhiteListControllerTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WhiteListControllerTest.java Sun Nov  6 00:47:07 2011
@@ -119,7 +119,7 @@ public class WhiteListControllerTest ext
     HttpClient client = new HttpClient();
     GetMethod get = new GetMethod(WHITELIST_SERVICE_URL_VALID);
     setAuthenticationCredentials(client);
-    get.setRequestHeader("Content-type", "application/json");
+    get.setRequestHeader("Accept", "application/json");
     client.executeMethod(get);
     int code = get.getStatusCode();
     assertEquals(200, code);

Modified: incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetAccessRequestPolicyControllerTest.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetAccessRequestPolicyControllerTest.java?rev=1198117&r1=1198116&r2=1198117&view=diff
==============================================================================
--- incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetAccessRequestPolicyControllerTest.java (original)
+++ incubator/wookie/trunk/src-tests/org/apache/wookie/tests/functional/WidgetAccessRequestPolicyControllerTest.java Sun Nov  6 00:47:07 2011
@@ -231,7 +231,7 @@ public class WidgetAccessRequestPolicyCo
   public void testGetWithoutAuthentication() throws HttpException, IOException {
     HttpClient client = new HttpClient();
     GetMethod get = new GetMethod(TEST_WARP_SERVICE_URL_VALID);
-    get.addRequestHeader("content-type", "text/xml");
+    get.addRequestHeader("Accept", "text/xml");
     client.executeMethod(get);
     int code = get.getStatusCode();
     assertEquals(401, code);
@@ -251,7 +251,7 @@ public class WidgetAccessRequestPolicyCo
     setAuthenticationCredentials(client);
     GetMethod get = new GetMethod(TEST_WARP_SERVICE_URL_VALID);
     get.setDoAuthentication(true);
-    get.addRequestHeader("content-type", "text/xml");
+    get.addRequestHeader("Accept", "text/xml");
     client.executeMethod(get);
     int code = get.getStatusCode();
     assertEquals(200, code);

Modified: incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java?rev=1198117&r1=1198116&r2=1198117&view=diff
==============================================================================
--- incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java (original)
+++ incubator/wookie/trunk/src/org/apache/wookie/controller/Controller.java Sun Nov  6 00:47:07 2011
@@ -333,7 +333,7 @@ public abstract class Controller extends
 	 * request, this method will return HTML (1)
 	 */
 	protected int format(HttpServletRequest request){
-		String type = request.getContentType();
+		String type = request.getHeader("Accept");
 		if (type == null){
 			// check for format parameters in the request
 			if (request.getParameter("format")!=null){