Fixing our default HTTP Accept header to be spec-compliant.
See bug http://code.google.com/p/android/issues/detail?id=5843
Also fixing a bug in the test webserver, where we weren't formatting
the headers properly. I'm dumbfounded how the tests passed previously;
although I fear that omitting the @TestTargetNew annotation might mean
that they weren't being run. I'll investigate that in a follow up.
diff --git a/libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java b/libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
index a082b47..b078727 100644
--- a/libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
+++ b/libcore/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java
@@ -1403,11 +1403,11 @@
}
output.append("\r\n"); //$NON-NLS-1$
}
- if (reqHeader.get("Accept") == null) { //$NON-NLS-1$
- // BEGIN android-changed
- output.append("Accept: *, */*\r\n"); //$NON-NLS-1$
- // END android-changed
- }
+ // BEGIN android-removed
+ // there's no utility in sending an "accept everything" header "*/*"
+ // if (reqHeader.get("Accept") == null) { //$NON-NLS-1$
+ // }
+ // END android-removed
if (httpVersion > 0 && reqHeader.get("Connection") == null) { //$NON-NLS-1$
output.append("Connection: Keep-Alive\r\n"); //$NON-NLS-1$
}
diff --git a/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java b/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
index 68ccb91..a74bf35 100644
--- a/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
+++ b/libcore/luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java
@@ -474,7 +474,7 @@
// validate the request by asking the server what was received
Map<String, String> headers = server.pathToRequest().get(path).getHeaders();
- assertEquals("*, */*", headers.get("Accept"));
+ assertNull(headers.get("Accept"));
assertEquals("application/x-www-form-urlencoded", headers.get("Content-Type"));
assertEquals("5", headers.get("Content-Length"));
assertEquals("localhost:" + port, headers.get("Host"));
diff --git a/libcore/support/src/test/java/tests/support/Support_TestWebServer.java b/libcore/support/src/test/java/tests/support/Support_TestWebServer.java
index b7e8b38..7d20237 100644
--- a/libcore/support/src/test/java/tests/support/Support_TestWebServer.java
+++ b/libcore/support/src/test/java/tests/support/Support_TestWebServer.java
@@ -561,7 +561,7 @@
while (buf[i] == ' ') {
i++;
}
- String headerValue = new String(buf, i, nread-i);
+ String headerValue = new String(buf, i, nread - i - 2); // drop \r\n
headers.put(headerName, headerValue);
return nread;