Revision: 5361
Author: [email protected]
Date: Wed Apr 17 16:02:09 2013
Log: Fix response Content-Type of proxy error responses.
https://codereview.appspot.com/8796047
CajolingService.handle was returning JSON as the Content-Type for
responses resulting from result == null (such as when the input URL
404's) instead of the proper type dependent on whether json-in-script
was requested.
See also revision 5298, which fixed this same problem for the success
cases.
[email protected]
http://code.google.com/p/google-caja/source/detail?r=5361
Modified:
/trunk/src/com/google/caja/service/CajolingService.java
/trunk/tests/com/google/caja/service/ProxyHandlerTest.java
=======================================
--- /trunk/src/com/google/caja/service/CajolingService.java Mon Sep 24
11:39:25 2012
+++ /trunk/src/com/google/caja/service/CajolingService.java Wed Apr 17
16:02:09 2013
@@ -123,7 +123,7 @@
}
result = FetchedData.fromBytes(
intermediateResponse.toByteArray(),
- ContentType.JSON.mimeType,
+ contentParams.a.mimeType,
"UTF-8",
InputSource.UNKNOWN);
}
=======================================
--- /trunk/tests/com/google/caja/service/ProxyHandlerTest.java Tue Feb 19
17:00:43 2013
+++ /trunk/tests/com/google/caja/service/ProxyHandlerTest.java Wed Apr 17
16:02:09 2013
@@ -44,4 +44,28 @@
"application/json");
assertSubstringsInJson(s, "html", "body {}");
}
+
+ public final void testJsonpAbsent() throws Exception {
+ // no registerUri; we want a failure
+ requestGet("?url=http://foo/bar"
+ + "&input-mime-type=text/css"
+ + "&alt=json-in-script"
+ + "&callback=foo"
+ + "&transform=PROXY"
+ + "&build-version=" + BuildInfo.getInstance().getBuildVersion(),
+ "text/javascript");
+ // TODO(kpreid): assertions about content, not just mime type
+ }
+
+ public final void testJsonAbsent() throws Exception {
+ // no registerUri; we want a failure
+ requestGet("?url=http://foo/bar"
+ + "&input-mime-type=text/css"
+ + "&alt=json"
+ + "&callback=foo"
+ + "&transform=PROXY"
+ + "&build-version=" + BuildInfo.getInstance().getBuildVersion(),
+ "application/json");
+ // TODO(kpreid): assertions about content, not just mime type
+ }
}
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.