Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rhino XHR 404 Response Error #31

Open
rwatler opened this issue Apr 12, 2011 · 0 comments
Open

Rhino XHR 404 Response Error #31

rwatler opened this issue Apr 12, 2011 · 0 comments

Comments

@rwatler
Copy link

rwatler commented Apr 12, 2011

In Rhino/Java, a 404 status received from a resource generates and FileNotFound exception. Depending on the server action and content type, an error stream may or may not be available. This patch checks to ensure the stream is defined before attempting to read from it.

--- /env-js/envjs/platform/rhino.js 2011-04-07 21:37:32.000000000 -0600
+++ envjs/platform/rhino.js 2011-04-11 12:22:42.000000000 -0600
@@ -385,12 +385,14 @@
             instream = connection.getErrorStream();
         }

-        while ((length = instream.read(buffer, 0, 1024)) != -1) {
-            outstream.write(buffer, 0, length);
+        if (instream) {
+            while ((length = instream.read(buffer, 0, 1024)) != -1) {
+                outstream.write(buffer, 0, length);
+            }
+            instream.close();
         }

         outstream.close();
-        instream.close();

         if(binary){
             xhr.responseText = new java.lang.String(outstream.toByteArray(), 'UTF-8')+'';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant