Index: test/groovy/org/codehaus/groovy/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy
===================================================================
--- test/groovy/org/codehaus/groovy/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy (revision 6726)
+++ test/groovy/org/codehaus/groovy/grails/web/servlet/mvc/RenderDynamicMethodTests.groovy (working copy)
@@ -35,7 +35,7 @@
}
def renderJSON = {
- render(contentType:"text/json") {
+ render(contentType:"application/json") {
foo {
bar("hello")
}
@@ -94,7 +94,7 @@
def testCtrl = ga.getControllerClass("TestController").newInstance()
testCtrl.renderJSON()
- assertEquals "text/json;charset=utf-8", response.contentType
+ assertEquals "application/json;charset=utf-8", response.contentType
assertEquals '{"foo":[{"bar":"hello"}]}', response.contentAsString
}
-}
\ No newline at end of file
+}
Index: test/groovy/org/codehaus/groovy/grails/web/mime/AcceptHeaderParserTests.groovy
===================================================================
--- test/groovy/org/codehaus/groovy/grails/web/mime/AcceptHeaderParserTests.groovy (revision 6726)
+++ test/groovy/org/codehaus/groovy/grails/web/mime/AcceptHeaderParserTests.groovy (working copy)
@@ -20,7 +20,7 @@
css: 'text/css',
cvs: 'text/csv',
all: '*/*',
- json: 'text/json',
+ json: 'application/json',
html: ['text/html','application/xhtml+xml']
]
""")
@@ -71,4 +71,4 @@
}
-}
\ No newline at end of file
+}
Index: test/groovy/org/codehaus/groovy/grails/web/mime/ContentFormatControllerTests.groovy
===================================================================
--- test/groovy/org/codehaus/groovy/grails/web/mime/ContentFormatControllerTests.groovy (revision 6726)
+++ test/groovy/org/codehaus/groovy/grails/web/mime/ContentFormatControllerTests.groovy (working copy)
@@ -22,7 +22,7 @@
css: 'text/css',
cvs: 'text/csv',
all: '*/*',
- json: 'text/json'
+ json: 'application/json'
]
""")
@@ -235,4 +235,4 @@
assertEquals "html", request.format
}
-}
\ No newline at end of file
+}
Index: test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsJSONMarshallingTests.groovy
===================================================================
--- test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsJSONMarshallingTests.groovy (revision 6726)
+++ test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsJSONMarshallingTests.groovy (working copy)
@@ -22,7 +22,7 @@
css: 'text/css',
cvs: 'text/csv',
all: '*/*',
- json: 'text/json'
+ json: 'application/json'
]
""")
@@ -66,7 +66,7 @@
void testJSONMarshallingIntoParamsObject() {
def controller = ga.getControllerClass("TestController").newInstance()
- controller.request.contentType = "text/json"
+ controller.request.contentType = "application/json"
controller.request.content = '{"id":1,"class":"Book","author":{"id":1,"class":"Author","name":"Stephen King"},"releaseDate":new Date(1196179518015),"title":"The Stand"}'.bytes
def model = controller.create()
@@ -81,4 +81,4 @@
}
-}
\ No newline at end of file
+}
Index: test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsXmlMarshallingTests.groovy
===================================================================
--- test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsXmlMarshallingTests.groovy (revision 6726)
+++ test/groovy/org/codehaus/groovy/grails/web/converters/AutoParamsXmlMarshallingTests.groovy (working copy)
@@ -22,7 +22,7 @@
css: 'text/css',
cvs: 'text/csv',
all: '*/*',
- json: 'text/json'
+ json: 'application/json'
]
""")
@@ -89,4 +89,4 @@
}
-}
\ No newline at end of file
+}
Index: ant/build/unit-test.xml
===================================================================
--- ant/build/unit-test.xml (revision 6726)
+++ ant/build/unit-test.xml (working copy)
@@ -44,7 +44,7 @@
This builder will set the content type of the response to "text/json"
+ *This builder will set the content type of the response to "application/json"
* *Sending a simple key value pair to the client requires this code:
* @@ -56,7 +56,7 @@ private static final String ARRAY = "a"; private static final String JSON_BUILDER = "JSON Builder: "; private static final String OBJECT = "o"; - private static final String TEXT_JSON = "text/json"; + private static final String TEXT_JSON = "application/json"; private static final String UTF_8 = "UTF-8"; Index: src/web/org/codehaus/groovy/grails/web/metaclass/RenderDynamicMethod.java =================================================================== --- src/web/org/codehaus/groovy/grails/web/metaclass/RenderDynamicMethod.java (revision 6726) +++ src/web/org/codehaus/groovy/grails/web/metaclass/RenderDynamicMethod.java (working copy) @@ -355,6 +355,10 @@ } private boolean isJSONResponse(HttpServletResponse response) { - return response.getContentType() != null && response.getContentType().indexOf("text/json") > -1; + String contentType = response.getContentType(); + if (contentType != null && (contentType.indexOf("application/json") > -1 || contentType.indexOf("text/json") > -1)) { + return true; + } + return false; } }