1.1 --- a/emul/mini/src/main/java/java/net/URL.java Thu Jan 24 19:36:40 2013 +0100
1.2 +++ b/emul/mini/src/main/java/java/net/URL.java Thu Jan 31 18:45:00 2013 +0100
1.3 @@ -987,6 +987,17 @@
1.4 )
1.5 private static native String loadText(String url) throws IOException;
1.6
1.7 + @JavaScriptBody(args = { "url", "arr" }, body = ""
1.8 + + "var request = new XMLHttpRequest();\n"
1.9 + + "request.open('GET', url, false);\n"
1.10 + + "request.overrideMimeType('text\\/plain; charset=x-user-defined');\n"
1.11 + + "request.send();\n"
1.12 + + "var t = request.responseText;\n"
1.13 + + "for (var i = 0; i < t.length; i++) arr.push(t.charCodeAt(i) & 0xff);\n"
1.14 + + "return arr;\n"
1.15 + )
1.16 + private static native Object loadBytes(String url, byte[] arr) throws IOException;
1.17 +
1.18 /**
1.19 * Gets the contents of this URL. This method is a shorthand for:
1.20 * <blockquote><pre>
1.21 @@ -1005,7 +1016,10 @@
1.22 throws java.io.IOException {
1.23 for (Class<?> c : classes) {
1.24 if (c == String.class) {
1.25 - return getContent();
1.26 + return loadText(toExternalForm());
1.27 + }
1.28 + if (c == byte[].class) {
1.29 + return loadBytes(toExternalForm(), new byte[0]);
1.30 }
1.31 }
1.32 return null;