diff options
author | Anwar Ghuloum <anwarg@google.com> | 2014-06-17 22:00:30 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-06-17 22:00:30 +0000 |
commit | 280a6d7eff0147bfbabe6d407e68ee911ebcb469 (patch) | |
tree | 38a1d979e36e0ed422ec69aafac937a564fb15ca | |
parent | 6188cc840d4987d2445740ce8a13dd335b6c6f73 (diff) | |
parent | 4aadbe01b75956c4a1c5af56723e5e6e3da25c47 (diff) | |
download | libcore-280a6d7eff0147bfbabe6d407e68ee911ebcb469.zip libcore-280a6d7eff0147bfbabe6d407e68ee911ebcb469.tar.gz libcore-280a6d7eff0147bfbabe6d407e68ee911ebcb469.tar.bz2 |
am 4aadbe01: Merge "Remove more." into lmp-preview-dev
* commit '4aadbe01b75956c4a1c5af56723e5e6e3da25c47':
Remove more.
5 files changed, 3 insertions, 99 deletions
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/file/FileURLConnectionTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/file/FileURLConnectionTest.java index 1f4ad1f..d6f2c01 100644 --- a/harmony-tests/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/file/FileURLConnectionTest.java +++ b/harmony-tests/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/file/FileURLConnectionTest.java @@ -112,8 +112,6 @@ public class FileURLConnectionTest extends TestCase { assertEquals(conn.getContentType(), conn.getHeaderField("content-type")); assertEquals(Integer.toString(conn.getContentLength()), conn.getHeaderField("content-length")); - assertEquals(Long.toString(conn.getContentLengthLong()), - conn.getHeaderField("content-length")); assertEquals(conn.getHeaderField(0), conn.getHeaderField("content-type")); assertEquals(conn.getHeaderField(1), conn.getHeaderField("content-length")); assertEquals(conn.getHeaderField(2), conn.getHeaderField("last-modified")); diff --git a/luni/src/main/java/java/net/URLConnection.java b/luni/src/main/java/java/net/URLConnection.java index 5147b7b..2fb3f45 100644 --- a/luni/src/main/java/java/net/URLConnection.java +++ b/luni/src/main/java/java/net/URLConnection.java @@ -316,17 +316,6 @@ public abstract class URLConnection { } /** - * Returns the content length in bytes specified by the response header field - * {@code content-length} or {@code -1} if this field is not set. - * - * @since 1.7 - * @hide 1.7 - */ - public long getContentLengthLong() { - return getHeaderFieldLong("Content-Length", -1); - } - - /** * Returns the MIME-type of the content specified by the response header field * {@code content-type} or {@code null} if type is unknown. * @@ -558,27 +547,6 @@ public abstract class URLConnection { } /** - * Returns the specified header value as a number. Returns the {@code - * defaultValue} if no such header field could be found or the value could - * not be parsed as a {@code long}. - * - * @param field - * the header field name whose value is needed. - * @param defaultValue - * the default value if no field has been found. - * @return the value of the specified header field as a number. - * @since 1.7 - * @hide 1.7 - */ - public long getHeaderFieldLong(String field, long defaultValue) { - try { - return Long.parseLong(getHeaderField(field)); - } catch (NumberFormatException e) { - return defaultValue; - } - } - - /** * Returns the name of the header field at the given position {@code posn} or * {@code null} if there are fewer than {@code posn} fields. The base * implementation of this method returns always {@code null}. diff --git a/luni/src/main/java/libcore/net/url/FileURLConnection.java b/luni/src/main/java/libcore/net/url/FileURLConnection.java index a6a575e..43eaa7d 100644 --- a/luni/src/main/java/libcore/net/url/FileURLConnection.java +++ b/luni/src/main/java/libcore/net/url/FileURLConnection.java @@ -225,12 +225,8 @@ public class FileURLConnection extends URLConnection { /** * Returns the length of the file in bytes. - * - * @return the length of the file - * @since 1.7 */ - @Override - public long getContentLengthLong() { + private long getContentLengthLong() { try { if (!connected) { connect(); diff --git a/luni/src/main/java/libcore/net/url/JarURLConnectionImpl.java b/luni/src/main/java/libcore/net/url/JarURLConnectionImpl.java index 231b078..b01a20a 100644 --- a/luni/src/main/java/libcore/net/url/JarURLConnectionImpl.java +++ b/luni/src/main/java/libcore/net/url/JarURLConnectionImpl.java @@ -265,23 +265,12 @@ public class JarURLConnectionImpl extends JarURLConnection { */ @Override public int getContentLength() { - long length = getContentLengthLong(); - return length > Integer.MAX_VALUE ? -1 : (int) length; - } - - /** - * Returns the content length of the resource. Test cases reveal that if the URL is referring to - * a Jar file, this method answers a content-length returned by URLConnection. For a jar entry - * it should return the entry's size. Otherwise, it will return -1. - */ - @Override - public long getContentLengthLong() { try { connect(); if (jarEntry == null) { - return jarFileURLConnection.getContentLengthLong(); + return jarFileURLConnection.getContentLength(); } - return getJarEntry().getSize(); + return (int) getJarEntry().getSize(); } catch (IOException e) { // Ignored } diff --git a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java index d3da174..d52b033 100644 --- a/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java +++ b/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java @@ -484,20 +484,6 @@ public class URLConnectionTest extends TestCase { fileURLCon.getInputStream().close(); } - /** - * {@link java.net.URLConnection#getContentLengthLong()} - */ - public void test_getContentLengthLong() throws Exception { - assertEquals(testString.getBytes().length, fileURLCon.getContentLengthLong()); - assertEquals(Support_TestWebData.test1.length, uc.getContentLengthLong()); - assertEquals(Support_TestWebData.test2.length, uc2.getContentLengthLong()); - - assertTrue(jarURLCon.getContentLength() > 0); - assertTrue(gifURLCon.getContentLength() > 0); - - fileURLCon.getInputStream().close(); - } - public void test_getContentType() throws Exception { assertTrue("getContentType failed: " + fileURLCon.getContentType(), fileURLCon.getContentType().contains("text/plain")); @@ -772,39 +758,6 @@ public class URLConnectionTest extends TestCase { } /** - * {@link java.net.URLConnection#getHeaderFieldLong(String, long)} - */ - public void test_getHeaderFieldLong() throws IOException, ParseException { - // Test getHeaderFieldLong() can read an int value. - Support_TestWebData params0 = Support_TestWebData.testParams[0]; - long hf = uc.getHeaderFieldLong("Content-Length", Long.MIN_VALUE); - assertEquals(params0.testLength, hf); - - // Test getHeaderFieldLong() for a value outside of the range of int. - Support_TestWebData params2 = Support_TestWebData.testParams[2]; - hf = uc3.getHeaderFieldLong("Content-Length", Long.MIN_VALUE); - assertEquals(params2.testLength, hf); - - // The remaining fields should be invalid or missing. Confirm the default is returned. - hf = uc3.getHeaderFieldLong("Content-Encoding", Long.MIN_VALUE); - assertEquals(Long.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("Content-Type", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("Date", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("Expires", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("SERVER", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("Last-Modified", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("accept-ranges", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - hf = uc3.getHeaderFieldInt("DoesNotExist", Integer.MIN_VALUE); - assertEquals(Integer.MIN_VALUE, hf); - } - - /** * {@link java.net.URLConnection#getHeaderField(java.lang.String)} */ public void test_getHeaderFieldLjava_lang_String() { |