History log of /libcore/luni/src/test/java/libcore/java/net/URLConnectionTest.java
Revision Date Author Comments
0e1afa1091f74a6228c01d8c7a8eebf001efdc57 13-Oct-2012 Elliott Hughes <enh@google.com> Fix ConcurrentCloseTest flakiness.

We can't rely on consuming all the listen(2) backlog. For the tests we've
seen fail because they sometimes connect rather than time out, switch to
an unroutable address.

(cherry-pick of babccbf9e429c4c78aca24c205825ceaaf7d3f37.)

Bug: 6971145
Change-Id: Ibfa412ff1ad7da7e63842d0162cc67a706e2b27e
b11e44a402eb0f9c5da1f7482fc1eabdd9adff47 20-Sep-2012 Jesse Wilson <jwilson@squareup.com> Fix a bug in tunnel construction and 'Connection: close' headers.

Based on https://github.com/square/okhttp/pull/30
(git fetch git://github.com/square/okhttp.git && git cherry-pick -x b8c51dc5bdc89d5487cbc110d6fe40389de16480)

Bug: http://code.google.com/p/android/issues/detail?id=37221
Bug: 7291446

(cherry picked from commit 4bedacd569fed2db56c518ed239412b3fe32245e)

Change-Id: I68c55e9259db91dbccca30824c00726094570304
6d41a7cc3cb4cc684c8bece69ddc55954812ad6e 24-Sep-2012 Narayan Kamath <narayan@google.com> Strip content length in requests with "transparent" gzip handling.

We need to strip both the Content-Length and the Content-Encoding
for such requests. In such requests, it will be the length of the
compressed response. We hide the fact that compression is taking place
from clients, so we shouldn't give them the content length either.

(cherry picked from commit f9d60aed414ae21811a6488f603333517f257b22)

Change-Id: Ic2776ecf020c34b1c55e2fb7e2f0728e553187a0
3edd28a92fc86a1260347d0995e65a815d73bbbe 16-Apr-2012 Mattias Petersson <mattias.petersson@sonymobile.com> Fix problem with Runtime.runFinalization()

This is a fix for a problem with runFinalization(). The
problem was that all FinalizerReferences to objects that had
not yet been garbage collected were lost when calling this
function. When a FinalizerReference was lost, it is was not
possible to call the finalize() method when the object
was garbage collected.

The result was that finalizers was sometimes never
called, which typically lead to memory leaks.

Also stop synchronizing on the class itself; use a private
lock instead.

Bug: 6907299
Bug: 5462944 # Synchronization on FinalizerReference.class
Change-Id: Ief515edbb5a1823c06d7371415d131165baef7f2
8155888a2c4e7cc28596deec28433e1984cfaf11 25-Jul-2012 Brian Carlstrom <bdc@google.com> Fix HttpURLConnection CloseGuard warning due to lack of close on GZIPInputStream

java.lang.Throwable: Explicit termination method 'end' not called
at dalvik.system.CloseGuard.open(CloseGuard.java:184)
at java.util.zip.Inflater.<init>(Inflater.java:82)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:96)
at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:523)
at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:831)
at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
at ...

Bug: 6602529
Change-Id: I9b49cbca561f8780d08844e566820087fdffc4d7
4ec2d0dea800397fb32227e0631246f4d2a73191 29-Jun-2012 Brian Carlstrom <bdc@google.com> HttpEngine should not attempt to cache proxy CONNECT responses

This fixes an issue where a bad proxy repsonse that included a body
would turn into an IllegalStateException instead of an IOException.

Bug: 6754912

Change-Id: I204ad975820693d6add2780d7b77360463e33710
deb26711801f9bfafcd5cad20963b3c3913404fd 04-Apr-2012 Elliott Hughes <enh@google.com> Add a test for an already-fixed publicly-reported bug.

Bug: http://code.google.com/p/android/issues/detail?id=28095
Change-Id: I26ff2834becce6f51e668ec71b4e5050b15f06cd
0731920fdf845358cc13ce78292f9e80e143f915 28-Mar-2012 Brian Carlstrom <bdc@google.com> Disable TLSv1.1 and TLSv1.2 by default

Bug: 6234791

Change-Id: I5d829211c9e1d5672fc96e42ef603c53d789e695
3d74b4bec8543e6e3f89eafe3afe0925f3a69f01 28-Mar-2012 Brian Carlstrom <bdc@google.com> Disable TLSv1.1 and TLSv1.2 by default

Bug: 6234791

Change-Id: I5d829211c9e1d5672fc96e42ef603c53d789e695
3e6dd45baa0d7f9b4fa06f4ade76e088b59cc7bf 16-Mar-2012 Brian Carlstrom <bdc@google.com> Tracking openssl-1.0.1

Bug: 6168278

Change-Id: I240d2cbc91f616fd486efc5203e2221c9896d90f
df29c7dc69965462cd19de8910b04c8cb463e57f 15-Feb-2012 Jesse Wilson <jessewilson@google.com> Don't attempt to parse an HTTP response body on HEAD requests.

Previously if the response had a Content-Length or Transfer-Encoding
header we assumed it had a body. This was untrue of HEAD requests.
This is not a regression.

Bug: http://code.google.com/p/android/issues/detail?id=24672
Change-Id: I264db2014e681a6f8e93cd40b0f1640c95103d21
a468471e8ccc2f642d5b2ae3c75873a74267ece2 26-Jan-2012 Jesse Wilson <jessewilson@google.com> Don't throw needlessly when returning the CacheResponse.

We were throwing under the premise that we'd always have
response headers before we had a cached body. But when the
user calls connect() we'll have queried the cache but we
won't necessarily have response headers from the server yet.
That's because connect() doesn't require a response to be ready.

Bug: http://b/5920659
Cherry-picked from: I9d69b44b5be3d0e29f14d8b83781f6e65c67582a

Change-Id: Ia403b42ddc9783fd1456164f4b7350da3ce80566
fa5e8dfe3c7ed144b0fbe69091628dedd6a3b961 21-Dec-2011 Jesse Wilson <jessewilson@google.com> Don't reuse an SSL socket if the socket factory has changed.

Bug: http://b/3042192
Change-Id: Iaa9deb69058afcca4ab79ca6ba745c55d1e9321a
abe4e615f473b387b1c00a738062a7c428f05a33 20-Dec-2011 Jesse Wilson <jessewilson@google.com> Unit test SSL fallback.

Bug: http://b/4462288
Change-Id: I9a29c70b24f235df15aa9a763ae5217e10e42f83
5757cb35ad2e58d7accb7f5d3db6f2d5e72f097d 16-Dec-2011 Jesse Wilson <jessewilson@google.com> Support multiple challenges for HTTP authentication.

This fixes the problem reported in the bug, but we still need
to give attention to the digest scheme. Currently we can't do
Basic auth if the HTTP response contains both a Digest challenge
and a Basic challenge!

Bug: http://code.google.com/p/android/issues/detail?id=19081
Change-Id: Ifffb307678c2afa0db1d50c1ef5fc49ec7769306
b2b02ac6cd42a69463fd172531aa1f9b9bb887a8 15-Dec-2011 Jesse Wilson <jessewilson@google.com> Change the way we cope with stale pooled connections.

Previously we'd attempt to detect if a connection was stale by
probing it. This was expensive (it relied on catching a 1-millisecond
read timing out with a SocketTimeoutException), and racy. If the
recycled connection was stale, the application would have to catch
the failure and retry.

The new approach is to try the stale connection directly and to recover
if that connection fails. This is simpler and avoids the isStale
heuristics.

This fixes some flakiness in URLConnectionTest tests like
testServerShutdownOutput and testServerClosesOutput.

Bug: http://b/2974888
Change-Id: I1f1711c0a6855f99e6ff9c348790740117c7ffb9
2d9fa917aae6a6da38e9d1eda05841ffdf8855bb 15-Dec-2011 Jesse Wilson <jessewilson@google.com> Document the effect on timeouts of having both IPv4 and IPv6 addresses

Bug: http://b/3441111

Change-Id: Ib4c2e3e0d8d86eb5eb77cf92a0814c7444fd153f
0613de89655e481fa610bfd4f1bcaeeae3272205 14-Dec-2011 Jesse Wilson <jessewilson@google.com> Document that disconnect() doesn't release sockets.

We could make disconnect() work, but it's a lot of complexity for
little gain. The core problem is that by the time the user calls
disconnect(), the connection has already been pooled. On the RI,
disconnect() will close a socket connection if it hasn't yet been
removed from the pool. Our pooling always-on or always-off behavior
is simpler and more predictable.

Bug: http://b/4148042
Change-Id: I61ef2ccb898f3ffaa08cedc70ee9e728fc1889b9
d0d626655f1d452070d3116678037e8759f807f4 10-Nov-2011 Jesse Wilson <jessewilson@google.com> Don't NullPointerException when a URL contains a space.

We end up creating a URI of http://and%20roid which has no host
name part because and%20roid is not a valid host name. It's unclear
where the best place to fail is. This is consistent with the RI
which doesn't fail until it attempts to connect.

Bug: http://code.google.com/p/android/issues/detail?id=16895
Change-Id: Ifa4dc3c651f4627e27622ed5cedfa820f9a35358
25a753691a80186cd4d7086b12c0e52225d95897 30-Sep-2011 Jesse Wilson <jessewilson@google.com> Fix chunked input stream's available() method to never return -1.

Change-Id: I6ea268e469675ef890010282dbe35ed5838cca73
http://code.google.com/p/android/issues/detail?id=20442
09336c914b4fc813e493acc82469b9ad89fd8694 07-Jun-2011 Jesse Wilson <jessewilson@google.com> Use external/mockwebserver in libcore

Change-Id: I4dac34f88b23484643bce31e5f25ac6eb1fea426
5292410e4ebf7fb5149eefd2f52fcb94c46690a6 24-May-2011 Jesse Wilson <jessewilson@google.com> Rewrite parsing for java.net.URL.

This fixes many broken cases on handling relative URLs.

We normalize all URLs by default. This will result
in more URL equality than before. Previously the URLs
http://android.com/a/../ and http://android.com/ were not
equal; now they are equal.

Change-Id: I8cf7be2e42eeb1386520be2698d8f14e0a55decb
http://b/4361656
ec6163ceac64902ccde3259e8a426f0f9ad6a88c 20-May-2011 Jesse Wilson <jessewilson@google.com> Add test cases inspired by Jetty-dependent Harmony tests.

Change-Id: Id8288e0524b64255c5d9808d3f5582708211d96b
1e518e80aeb8c27d49d51e5c69173d3e08fb9ec7 09-May-2011 Jesse Wilson <jessewilson@google.com> Deduplicate a unit test merged in from upstream.

Change-Id: Ia5f4ad1753fa6bb2ce4dd5fdf4c978e1ff0ffa80
http://b/4188137
68b8820c82a524388a32501fa9b423d77b4b73b6 09-May-2011 Jesse Wilson <jessewilson@google.com> Deduplicate a test that was duplicated by an automerge.

Change-Id: Id8ef04b21c1132db224c69437428bbe4f5890a6a
http://b/4188137
5e8b5a55eda914b67c62b4e77152922d5c77eb68 29-Mar-2011 Jesse Wilson <jessewilson@google.com> Don't read from the delegate stream after we close it.

Honeycomb MR2 patch cherry-picked from bc4c79c6a2059003f695f7ad204de36700e8d701

Change-Id: Ib379595a1e6b2ed3b16d4d82c744b00e4b576c51
http://b/4188137
c996149b500fc4825156106554457fe2394ae087 06-May-2011 Jesse Wilson <jessewilson@google.com> Fix proxy+HTTPS to handle authentication requests from the proxy.

Previously I'd introduced a bug by assuming that CONNECT
responses would always be successful.

Change-Id: Iaf0caf67f52154f6951a20284c75db0090843b99
http://b/4188137
d742d7fc7f0593eb8c6e4ac9dd4c0f6a80374e46 05-May-2011 Jesse Wilson <jessewilson@google.com> Use GET after a POST is redirected.

Also dropping support for response code 305 Use Proxy, which
is seldom used, and whose behavior is quite different from
Chrome and Firefox. This is an intentional delta from the RI.

Also testing disconnect().

Change-Id: I80433f4776a2cfc5e228179421a787a44a4ded69
http://b/3180373
953df613522e12a418cb7cb73248594d6c9f53d4 03-May-2011 Jesse Wilson <jessewilson@google.com> Refactor HttpURLConnection implementation.

Break HttpURLConnectionImpl into two parts: the part that
implements the Java API (that follows redirects etc.) and
the part that speaks HTTP. The HTTP part is called HttpEngine,
and it can only be used for a single HTTP request. This makes
it easier to set request properties that only apply to a
single socket request.

Tests for 'Vary', 'Content-Location' and warnings.

For simplicity of implementation I've chosen not to support
'Vary' at this time.

The 'Content-Location' header doesn't require any work from
the cache.

Warnings are ugly but allow the caller to identify when the
cache results may be problematic.

Also breaking HttpResponseCache's dependency on HttpURLConnectionImpl
so it can be tested on the RI.

Change-Id: Idbabb51251f479c2cdea4e0fceb029bfd07182be
http://b/3180373
0c59055dd24e1659f85d9ff7e2148883f663bd62 27-Apr-2011 Jesse Wilson <jessewilson@google.com> Support conditional gets in HttpURLConnection.

This is the first step towards adding an HTTP response cache.
There's still much to do; details are listed on the bug.

Change-Id: Ie693fe424d1d90e90576fc959595e4d96a31f767
http://b/3180373
5f03a4682a71e56535059258a4d41150b99177d7 05-Apr-2011 Jesse Wilson <jessewilson@google.com> Fix a test that was merged from both GB and HC.

Change-Id: I8cf7dec2dcec177669a04951635c95c78d8c7aaf
http://b/4188137
bc4c79c6a2059003f695f7ad204de36700e8d701 31-Mar-2011 Jesse Wilson <jessewilson@google.com> Don't read from the delegate stream after we close it.

Change-Id: Ib724b170f7ec10ea0025c0e2e7978119fd070eb6
http://b/4188137
0c2fd828abec671333b8b88281825fd27a783723 30-Mar-2011 Jesse Wilson <jessewilson@google.com> Fix MockWebServer to use the same hostname as TestKeyStore.

Change-Id: I31c9f6e9add87a17737eac4f09949540e5da8cb5
f241d462634527692b7d99335cdc8c11883ac966 29-Mar-2011 Jesse Wilson <jessewilson@google.com> Don't read from the delegate stream after we close it.

Change-Id: I9a018ca88373d5f317335e35fc6ca43c5473490e
http://b/4188137
32559028b14b9b321b10eede050afd554a376569 09-Feb-2011 Jesse Wilson <jessewilson@google.com> Use the same code to encode and fix poorly encoded URLs.

Don't permit digits outside of ASCII.

Change-Id: I47b756c32e67b7415e35ae9eb55b735d1c22a36d
http://b/3436051
38db242d16a5a31fd86c519b817ae94c5fc89417 27-Jan-2011 Elliott Hughes <enh@google.com> Consistently use "expected" for expected exceptions in our tests.

Change-Id: I796624fb53dbba420d43858741c9a97b4fb8d017
afd9b157f467b7c4f2f0b5592dca72f18d844602 20-Jan-2011 Jesse Wilson <jessewilson@google.com> Handle the CacheResponse returning a null body.

Change-Id: I45c4d6b7cac5cabd8c42f5e17d110fb5b3ecc9cc
http://b/3373699
d1b5e5da828434388e486a388710d21e4306dae0 20-Jan-2011 Jesse Wilson <jessewilson@google.com> Fix URL character bugs by adding yet another encoder.

We don't have an encoder that ignores already escaped
characters.

Change-Id: I9ff080ad1745136b7d7313d78af2b0ca1785b200
http://b/3360947
b7f4d6c3968c372767b2510f38a3d506067aced6 13-Jan-2011 Jesse Wilson <jessewilson@google.com> Move tests from android.core.URLTest to URLConnectionTest.

This includes some changes to MockWebServer to make it stop
accepting connections as soon as its response queue is empty.

Change-Id: I5a6bcdf1c03d0c36b11552ae086d0dece0440f64
http://b/1158780
fa9f91a486b81b19db13eab59e704179381de22f 12-Jan-2011 Jesse Wilson <jessewilson@google.com> Fix typo in testResponseCacheCallbackApis().

Embarassing. Test passes with the typo fixed!

Change-Id: Ic348f68c0e720163ca77b125415b01e840c7412d
f14bee4dbf9f724a177a85a7b73f7b0bc6df1ec0 06-Jan-2011 Jesse Wilson <jessewilson@google.com> Return HTTP headers even if there is no HTTP response body.

Also add a test to demonstrate that we've bug 7787.
http://code.google.com/p/android/issues/detail?id=7787

Change-Id: I4e320835516c05ec9e305661b5bbb1e59b278183
e942f46f10bb9384a1b186b3d7b74f9704c57090 17-Dec-2010 Jesse Wilson <jessewilson@google.com> Test that HttpURLConnection responds gracefully when the server closes a socket.

Change-Id: I5110d58d91e7c6f8f7553ad400f0bd841bcf07b6
http://b/2612240
2915378e253f08e47fe5a9bfd026cd1ca7c6c351 16-Dec-2010 Brian Carlstrom <bdc@google.com> HttpsURLConnection retry should not invoke X509TrustManager and HostnameVerifier more than once

Summary:

In 2.3, HttpsURLConnection was change to retry TLS connections as SSL
connections w/o compression to deal with servers that are TLS
intolerant. However, if the handshake proceeded to the point of
invoking the X509TrustManager, we should not retry. Similarly, if we
should not invoke the HostnameVerifier repeatedly, and need to wait
until the SSL handshake has completed.

Tested with (includes two new tests for this issue):
libcore/luni/src/test/java/libcore/javax/net/ssl/
libcore/luni/src/test/java/libcore/java/net/URLConnectionTest.java
libcore/luni/src/test/java/org/apache/harmony/luni/tests/internal/net/www/protocol/https/HttpsURLConnectionTest.java

Details:

HttpConnection.setupSecureSocket has been broken into two
pieces. setupSecureSocket now just does the SSL
handshaking. verifySecureSocketHostname now does the
verification. The old HttpConnection code was careful never to
assign its sslSocket field until verification was complete. A new
unverifiedSocket field is added to store the sslSocket before
verification is completed by verifySecureSocketHostname.

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConnection.java

HttpsEngine.makeConnection now skips TLS intolerant retry if the
reason for the makeSslConnection failure was a
CertificateException, since that implies that we failed during
certification validation after initial handshaking. We also
prevent retrying hostname verification by moving it out of
makeSslConnection and only doing it on new SSL connections,
tracking the changes to HttpConnection.setupSecureSocket mentioned
above. We also now skip the redundant call to setUpTransportIO in
makeSslConnection on reused SSLSockets.

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnectionImpl.java

Instead of throwing away the underlying CertificateExceptions, set
them as the cause of the SSLExceptions. This is what the RI does
in the case of X509TrustManager failures and is now used by
HttpsEngine.makeConnection.

luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSessionImpl.java
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java

Added new testConnectViaHttpsToUntrustedServer which makes sure
that connections are not retried on certificate verification
failure.

luni/src/test/java/libcore/java/net/URLConnectionTest.java

Added new test_SSLSocket_untrustedServer that verifies that an
SSLHandshakeException is thown containing a CertificateException
is thrown on certificate verification problems.

luni/src/test/java/libcore/javax/net/ssl/SSLSocketTest.java

Added second test CA and a new TestKeyStore.getClientCA2 test key
store that does not trust the primary test key stores. This is
useful for negative testing and is used in the above two new
tests.

support/src/test/java/libcore/java/security/TestKeyStore.java

Issue: http://code.google.com/p/android/issues/detail?id=13178
Bug: 3292412

Change-Id: I37136bb65f04d2bceaf2f32f542d6432c8b76ad4
c6dae581716b9362a5c7f166c80a7f2b46ed1124 06-Nov-2010 Jesse Wilson <jessewilson@google.com> Throw the expected exception after the response failed.

Change-Id: I4c2ed726d41d6b55e27a503467a412fa05242383
http://b/3172197
35eef71e8ce721c4199c525890ecc1a263054596 02-Dec-2010 Jesse Wilson <jessewilson@google.com> Fix two bugs with HTTPS + file uploads.

Firstly, we weren't echoing calls to setFixedLengthStreamingMode
and setChunkedStreamingMode from the HTTPS adapter down to the
real HTTP client.

Secondly, we were calling setTransportIO twice, and the second
call destroyed the buffer of our request body stream. That buffer
has only existed since change Id22a8449118a4b8dd13e71915700ac78803d2d9f,
(November 2, 2010) so the impact of that problem is limited.

Change-Id: Icb0eb2e0ca4e201a629bd74c3b98e852f6cc0fd3
http://code.google.com/p/android/issues/detail?id=12860
253851cdb2904082c205949da273c455d197c083 01-Dec-2010 Jesse Wilson <jessewilson@google.com> Do not merge: Fix a bug where we weren't pooling connections due to mismatched URLs.

Already committed to master as change 78504.

Change-Id: Ib883e92bb03b142f34449ef1314c57878dcc00f0

http://b/3169861
dbc42ad94ce37b3178e14b50496914c267d6cea6 16-Nov-2010 Brian Carlstrom <bdc@google.com> HttpsURLConnection fixes to pass URLConnectionTest and HttpsURLConnectionTest

Add public getSecureSocket so that HttpsURLConnection can reset its sslSocket field on reused connections.

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpConnection.java

discardIntermediateResponse now maintain old values for
intermediateReponse, which is necessary when retrying the CONNECT
method with proxy authorization.

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/http/HttpURLConnectionImpl.java

Clear sslSocket before retrying makeSslConnection to ensure we reconnect.
makeSslConnection now resets sslSocket on resumed connection.
makeSslConnection now exits early on existing connection.

luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/https/HttpsURLConnectionImpl.java

git cherry-pick -e 4df5be29bdffc09e7368c03423a0bef85fa26ac5
Bug: 3184701
Change-Id: Ida3c027f79e5e29968263ac761d4f4f79d063a27
5bcbe1c84468a25fec1e5b4e1dd636f917c73422 16-Nov-2010 Brian Carlstrom <bdc@google.com> HttpsURLConnectionTest rewrite and URLConnectionTest updates

Rewrote HttpsURLConnectionTest to work with current SSLSocket
implementation which more strictly follows RI behavior.

Also made upates to URLConnectionTest related to HttpsURLConnection
- changed assertContent call connect() explictly to illustrate problem
with https proxy case also seen by HttpsURLConnectionTest
- Rewrote testConnectTimeouts to work reliably. Before if often
worked on WiFi but not on mobile networks where a "HTTP/1.1 501 Bad
Gateway" would be seen causing a FileNotFoundException.
- Changed testConnectViaHttpProxyToHttpsUsingHttpProxySystemProperty
to match expectation that https does not use the http.proxyHost
values. Added new testConnectViaHttpProxyToHttpsUsingProxyArgWithNoProxy
which should have the same behavior as the fixed
testConnectViaHttpProxyToHttpsUsingHttpProxySystemProperty

git cherry-pick -e f02c695ed03e708623d9365dec26d533356ef2d0

Bug: 3184701
Change-Id: Id25f619d2437db607deaf35aeb1d5e817514b92f
5fc5dde4c719c1dfdac46b67d5d2e4884d07721e 16-Nov-2010 Elliott Hughes <enh@google.com> Improve ConcurrentCloseTest.

No more flaky use of 10.* addresses.

Bug: 3044772
Change-Id: I5ca8dc431b50950efdc818efe73eb9aba76ea67f
f02c695ed03e708623d9365dec26d533356ef2d0 16-Nov-2010 Brian Carlstrom <bdc@google.com> HttpsURLConnectionTest rewrite and URLConnectionTest updates

Rewrote HttpsURLConnectionTest to work with current SSLSocket
implementation which more strictly follows RI behavior.

Also made upates to URLConnectionTest related to HttpsURLConnection
- changed assertContent call connect() explictly to illustrate problem
with https proxy case also seen by HttpsURLConnectionTest
- Rewrote testConnectTimeouts to work reliably. Before if often
worked on WiFi but not on mobile networks where a "HTTP/1.1 501 Bad
Gateway" would be seen causing a FileNotFoundException.
- Changed testConnectViaHttpProxyToHttpsUsingHttpProxySystemProperty
to match expectation that https does not use the http.proxyHost
values. Added new testConnectViaHttpProxyToHttpsUsingProxyArgWithNoProxy
which should have the same behavior as the fixed
testConnectViaHttpProxyToHttpsUsingHttpProxySystemProperty

Change-Id: I397f55905524e2bbb587533f258ef0418ca8af80
06e15e6c528fcb773bedb43e34b0577312570927 05-Nov-2010 Jesse Wilson <jessewilson@google.com> Fix a bug where we weren't pooling connections due to mismatched URLs.

Change-Id: I13bebc94189192c3f8d959e521989591d2fca3e2
c1a675c80c69decadb736b245f0366f93a94a462 29-Oct-2010 Jesse Wilson <jessewilson@google.com> Remove the tree map in the HTTP headers.

This map is intended make looking up headers faster, but for real-world
sized datasets we spend more energy maintaining the map than we save from
using it.

I benchmarked the Android Market's HTTP connections' header use and it's
significantly faster to skip the map:

run us linear runtime
map+list 413.1 ==============================
list only 65.8 ====

Change-Id: I5b8fef6f999eb1bfe53eea2781f63cdd1002a273
8ac847a52e72f0cefbb20a6850ae04468d433a9e 28-Oct-2010 Jesse Wilson <jessewilson@google.com> Fix broken interactions between HTTP response caches and redirects.

This fixes several specific problems:
- HTTP header map didn't contain the status line (under the null key)
- response code, message and version weren't set by caches
- caches didn't work with redirects

This change also makes some significant cleanup to the Headers class.
We might be able to simplify this further by dropping the map, should
that prove efficient enough.

Change-Id: Ib79ec17bef5978b3234f68102114eee7d4b7cda2
http://b/3139211
http://b/3139211
37dcf5581f177229ca6c8e7d0d640361640bfb00 27-Oct-2010 Jesse Wilson <jessewilson@google.com> Fix ResponseCache to support caching of HTTPS responses.

Previously it would fail with an internal error because of
inconsistencies because HttpURLConnectionImpl claimed to be
'connected' when it had a cache hit, and HttpsURLConnection
acted upon this by talking to its sockets.

Change-Id: I51f4215ceb9c5fd851223a501488306fa6d382b1
http://b/3043966
984fcff696380abd6ea14e80030f9fd2d09dbad0 14-Oct-2010 Jesse Wilson <jessewilson@google.com> Tests for HTTP bugs using HTTPS through a proxy.

Change-Id: I01b470204d4da46016794ab7040d5751e7116958
http://b/3097277
http://b/3097518
f29ad8a60254345d1943d1b3836482395a7c916f 30-Sep-2010 Jesse Wilson <jessewilson@google.com> Don't explode if flush() is called when an HTTP upload stream is closed.

Streams like BufferedOutputStream always call flush() even if it is
a no-op. These flushes must be permitted for compatibility with apps
that don't call close() until after the response has been retrieved.

Change-Id: Ic5c86ab6050c6c4d166c44ae5b4fc7a1688e7e45
http://b/3038470
1f8243e3d2b5a3f8e0398c304d1dea0395cbc368 28-Sep-2010 Jesse Wilson <jessewilson@google.com> Remove java.net tests that are redundant with Harmony.

Change-Id: I01d6b3633a6de8a075982975d4cbf6c08e757490
00feece22909b7dc79fc96d666d157390b93858e 24-Sep-2010 Jesse Wilson <jessewilson@google.com> Strip usage of the term 'localhost' from URLConnectionTest.

Change-Id: I8ea7923c3ea72728c7df64c13bdd6f94b91be121
http://b/3032912
ef66494dce45a0b7ec22ec3fb20c60096517a4e3 22-Sep-2010 Jesse Wilson <jessewilson@google.com> Fix problem where single-byte reads were unsigned.

Change-Id: Ib0bc273698b71d13a90a03a8c60498ad7de5ad9d
http://b/3023872
d4bddd7d1fb7b1b7f0836648228235c6e4b56a18 16-Sep-2010 Jesse Wilson <jessewilson@google.com> Fix two HTTP issues that came up when writing HttpURLConnection docs.

We're now more careful about which headers are sent to HTTP proxies.
And getContentEncoding() is better documented.

Change-Id: I04241f99c2f32c25ba005fbd6ff9ef7236c3c9d3
8116f7e97e00d223e7fbe5c950c9a5e3277de124 17-Sep-2010 Jesse Wilson <jessewilson@google.com> Don't leave the Content-Encoding header around after transparent gzip.

Otherwise clients may be tempted to double-decompress.
http://b/issue?id=3009828

Change-Id: I4832da1c2aff9bad8d452ffc4a0f98ee27d44f49
65d890eb22aeba9b009ee642ffd4fff48a6f98ae 08-Sep-2010 Jesse Wilson <jessewilson@google.com> Cope with HTTP responses where the response code and headers disagree.

See http://b/issue?id=2981779

Change-Id: I0e4ed8f0cc606aa419704ba2eb5cd9938b5ff320
b7155fd57239e986bbaba254a91aeb9600d60305 03-Sep-2010 Jesse Wilson <jessewilson@google.com> Fixing a broken pipe with HttpsURLConnection connection reuse.

We had a bug where we were peeking a byte from the raw socket
stream rather than the encrypted stream when we were attempting
to reuse an HTTPS connection. The raw stream field shouldn't
have been initialized, but setupTransportIO() did it while the
connection was being established.

This fixes setupTransportIO() to not initialize the fields
and isStale() to use the SSL fields if they exist.

See http://code.google.com/p/android/issues/detail?id=8625

Change-Id: Idd5b6f20e098adf436997829940707548896bedb
50ae32218918eae80298bd1ab8e4f588bbbabdb2 01-Sep-2010 Jesse Wilson <jessewilson@google.com> Configure HttpURLConnection to prefer gzipped content by default.

This is not what the RI does. But the bandwidth savings is substantial,
and we can offer it almost for free.

See http://code.google.com/p/android/issues/detail?id=9390

Change-Id: I43c3fae8938f33809f2526d2d0e1cc5e08ae1202
f418bf447fd007cd2ec2d45b4b0399a11904e9b4 30-Aug-2010 Jesse Wilson <jessewilson@google.com> Support "Connection: close" from both request and response.

This is a rewrite of fix for the same problem in AOSP master:
https://review.source.android.com/16757

This expands on that fix by supporting "Connection: close" on
redirects by adding test coverage.

Change-Id: Ia0daa9d83cf9f557b4e9a99b2c51345c98c6db14
125f068f0a6cd739beac97821c9421cf8317cc87 20-Aug-2010 Jesse Wilson <jessewilson@google.com> Fix a bug when user sets "Content-Encoding: chunked" manually.

We used to try to build a -1-sized ByteArrayOutputStream, which
failed miserably with an exception.

Change-Id: Ia6fa72c639a14c03f03b6f73083ce37ffab8b4e5
4557728efb66c455a52b7669a8eefef7a9e54854 11-Aug-2010 Jesse Wilson <jessewilson@google.com> Moving tests to be under the libcore.* package.

This is indended to make it easier to run on VMs that restrict the packages
from which application classes can be loaded. For example, on the RI you need
to use the bootclasspath to load these tests.

Change-Id: I52193f35c5fcca18b5a3e1d280505b1e29b388af