Reviewers: Jasvir,

Description:
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.

Please review this at https://codereview.appspot.com/8796047/

Affected files:
  M     src/com/google/caja/service/CajolingService.java
  M     tests/com/google/caja/service/ProxyHandlerTest.java


Index: tests/com/google/caja/service/ProxyHandlerTest.java
===================================================================
--- tests/com/google/caja/service/ProxyHandlerTest.java (revision 5360)
+++ tests/com/google/caja/service/ProxyHandlerTest.java (working copy)
@@ -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
+  }
 }
Index: src/com/google/caja/service/CajolingService.java
===================================================================
--- src/com/google/caja/service/CajolingService.java    (revision 5360)
+++ src/com/google/caja/service/CajolingService.java    (working copy)
@@ -123,7 +123,7 @@
       }
       result = FetchedData.fromBytes(
           intermediateResponse.toByteArray(),
-          ContentType.JSON.mimeType,
+          contentParams.a.mimeType,
           "UTF-8",
           InputSource.UNKNOWN);
     }


--

--- 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.


Reply via email to