summaryrefslogtreecommitdiffstats
path: root/luni/src
diff options
context:
space:
mode:
authorJesse Wilson <jessewilson@google.com>2009-09-16 18:01:52 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-09-16 18:01:52 -0700
commitcdc4941b17d255933bfde70d423a2ade6f26e850 (patch)
tree673f0ddcbf5b8707fd7c40d62b762e7555bda50a /luni/src
parenta33a33f07cc59ed4fc7e447da395b3fc3d7b4727 (diff)
parentbe318b3a1d78cf1ef5597607a7cf77b8530d0295 (diff)
downloadlibcore-cdc4941b17d255933bfde70d423a2ade6f26e850.zip
libcore-cdc4941b17d255933bfde70d423a2ade6f26e850.tar.gz
libcore-cdc4941b17d255933bfde70d423a2ade6f26e850.tar.bz2
am cc4c69bc: am 023a932a: Merge change 24788 into eclair
Merge commit 'cc4c69bc91a8813e654095acf13e80a4d478eb24' * commit 'cc4c69bc91a8813e654095acf13e80a4d478eb24': Fixing the delimiter for the HTTP "Accept" header to be well-formed.
Diffstat (limited to 'luni/src')
-rw-r--r--luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java4
-rw-r--r--luni/src/test/java/org/apache/harmony/luni/tests/java/net/URLConnectionTest.java26
2 files changed, 25 insertions, 5 deletions
diff --git a/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java b/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
index 104a981..2dea92b 100644
--- a/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
+++ b/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnection.java
@@ -1385,7 +1385,9 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
output.append("\r\n"); //$NON-NLS-1$
}
if (reqHeader.get("Accept") == null) { //$NON-NLS-1$
- output.append("Accept: *; */*\r\n"); //$NON-NLS-1$
+ // BEGIN android-changed
+ output.append("Accept: *, */*\r\n"); //$NON-NLS-1$
+ // END android-changed
}
if (httpVersion > 0 && reqHeader.get("Connection") == null) { //$NON-NLS-1$
output.append("Connection: Keep-Alive\r\n"); //$NON-NLS-1$
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 bcd73d8..68ccb91 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
@@ -17,14 +17,11 @@
package org.apache.harmony.luni.tests.java.net;
import dalvik.annotation.BrokenTest;
-import dalvik.annotation.KnownFailure;
import dalvik.annotation.TestLevel;
import dalvik.annotation.TestTargetClass;
import dalvik.annotation.TestTargetNew;
import dalvik.annotation.TestTargets;
-
import junit.framework.TestCase;
-
import tests.support.Support_Configuration;
import tests.support.Support_PortManager;
import tests.support.Support_TestWebData;
@@ -59,7 +56,6 @@ import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.UnknownServiceException;
import java.security.Permission;
-import java.text.DateFormat;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Calendar;
@@ -463,6 +459,28 @@ public class URLConnectionTest extends TestCase {
}
}
+ public void testHttpPostHeaders() throws IOException {
+ String path = "/" + Math.random();
+ HttpURLConnection connection = (HttpURLConnection)
+ new URL("http://localhost:" + port + path).openConnection();
+
+ // post a request
+ connection.setDoOutput(true);
+ OutputStreamWriter writer
+ = new OutputStreamWriter(connection.getOutputStream());
+ writer.write("hello");
+ writer.flush();
+ assertEquals(200, connection.getResponseCode());
+
+ // validate the request by asking the server what was received
+ Map<String, String> headers = server.pathToRequest().get(path).getHeaders();
+ assertEquals("*, */*", 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"));
+ // TODO: test User-Agent?
+ }
+
/**
* @throws IOException
* @tests {@link java.net.URLConnection#getAllowUserInteraction()}