Author: jleroux
Date: Wed Sep  9 07:16:18 2015
New Revision: 1701915

URL: http://svn.apache.org/r1701915
Log:
A completed patch from Oleg Andreyev for "Using official content type for json 
requests" https://issues.apache.org/jira/browse/OFBIZ-6608

I suggest using application/json instead of application/x-json as it is 
official content type. It seems x-json does not cause any problem for the time 
being but browsers will load json responses correctly without asking for 
download. It's handy in development time. It also matches JQuery Accept header.

jleroux: I also used it in Solr



Modified:
    ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java
    
ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrContextFilter.java

Modified: ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java?rev=1701915&r1=1701914&r2=1701915&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java 
(original)
+++ ofbiz/trunk/framework/common/src/org/ofbiz/common/CommonEvents.java Wed Sep 
 9 07:16:18 2015
@@ -313,8 +313,8 @@ public class CommonEvents {
             jsonStr = "//" + jsonStr;
         }
 
-        // set the X-JSON content type
-        response.setContentType("application/x-json");
+        // set the JSON content type
+        response.setContentType("application/json");
         // jsonStr.length is not reliable for unicode characters
         response.setContentLength(jsonStr.getBytes("UTF8").length);
 

Modified: 
ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrContextFilter.java
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrContextFilter.java?rev=1701915&r1=1701914&r2=1701915&view=diff
==============================================================================
--- 
ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrContextFilter.java
 (original)
+++ 
ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrContextFilter.java
 Wed Sep  9 07:16:18 2015
@@ -196,7 +196,7 @@ public class OFBizSolrContextFilter exte
                     }
                 }
                 if (servletPath.startsWith("/admin/") && 
(UtilValidate.isEmpty(userLogin) || !LoginWorker.hasBasePermission(userLogin, 
httpRequest))) {
-                    response.setContentType("application/x-json");
+                    response.setContentType("application/json");
                     MapToJSON mapToJson = new MapToJSON();
                     JSON json;
                     try {
@@ -219,7 +219,7 @@ public class OFBizSolrContextFilter exte
                     // NOTE: the update requests are defined in an index's 
solrconfig.xml
                     // get the Solr index name from the request
                     if (UtilValidate.isEmpty(userLogin) || 
!LoginWorker.hasBasePermission(userLogin, httpRequest)) {
-                        httpResponse.setContentType("application/x-json");
+                        httpResponse.setContentType("application/json");
                         MapToJSON mapToJson = new MapToJSON();
                         Map<String, Object> responseHeader = new 
HashMap<String, Object>();
                         JSON json;


Reply via email to