History log of /libcore/support/src/test/java/tests/http/MockResponse.java
Revision Date Author Comments
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
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
4559b1d37edcb5d7f1da086cf2e3290388d74f46 23-Jul-2010 Brian Carlstrom <bdc@google.com> Support for TLS Extensions enabled SSLSockets with fallback to vanila SSL

See also b/1569612

Summary:
- OpenSSlSocket support for SNI, session tickets, compression
- URLConnection mimics Chrome behavior of trying connection with these enabled,
falling back to SSL w/o encryption on failure

Details:

libcore

URLConnection https retry

Change HttpConnection.getSecureSocket to enable non-standard features on first
connection attempt. On second attempt, we back off to SSLv3 from
TLSv1, mimicking Chrome's behavior.

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

Change HttpsEngine.connect to implement SSL reconnect

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

OpenSSL SSLSocket implementation

OpenSSLSocketImpl and OpenSSLServerSocketImpl now have an array of
enabled compression methods interface and implementation to
parallel that of procotols and ciphersuites.

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

OpenSSLSessionImpl now has a cache of the native
compressionMethod. Also replaced "gives" javadoc working with
"returns".

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

OpenSSLSocketImpl session caching now needs to skip cached
sessions with mismatched compression requirements.

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

OpenSSLSocketImpl.startHandshake now uses NativeCrypto to support
our non-standard extensions.

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

NativeCrypto changes
- Added declaration of SSL options for tickets and compression.
- Added general "compression methods" interface
paralleling "cipher suites" and "protocols" interfaces.
- Added SSL_set_tlsext_host_name to set SNI (Server Name Indication) value
- Added SSL_get_servername to read SNI (Server Name Indication) value
- Added SSL_SESSION_compress_meth read negotiated compression method
- SSL_new makes sure to default compression to off for compatibility
luni/src/main/java/org/apache/harmony/xnet/provider/jsse/NativeCrypto.java
luni/src/main/native/NativeCrypto.cpp

Testing

Added URLConnectionTest.testConnectViaHttpsWithSSLFallback to make
sure we properly retry an https connection if the server
terminates unexpectedly. Fixed up
URLConnectionTest.testHttpsWithCustomTrustManager with new
expected certificate chain. Fixed a few mistaken
TestSSLContext.serverContext uses to clientContext

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

Added test_SSL_set_tlsext_host_name, test_SSL_get_servername,
test_SSL_SESSION_compress_meth. Added a number of missing fail()
calls in expected exception cases which caught one test with
mistaken expectations. Removed some unnecessary scopes. Fixed some
badly scoped catch blocks.

luni/src/test/java/org/apache/harmony/xnet/provider/jsse/NativeCryptoTest.java

Changed MockWebServer to support a new MockResponse propery of
disconnectAtStart, which immediately terminates the connection

support/src/test/java/tests/http/MockResponse.java
support/src/test/java/tests/http/MockWebServer.java

external/openssl

Restore -ZLIB to OpenSSL build. Note that NativeCrypto.SSL_new
disables compression by for default SSLSocket for compatibility.
android-config.mk
Force clean build with new CFLAGS
CleanSpec.mk

Change-Id: Iba6268f9096f2be43f0d30de151dd3fd0aea4a81
51e468abf2628ce964d3657042f3ac8f2c947504 26-Jun-2010 Jesse Wilson <jessewilson@google.com> Fixing response cache and connection reuse for HTTP client.

The code splits our HTTP input streams into four (!) inner
classes. The base class takes care of ensuring split() and
single byte reads get cached and call disconnect() as necessary.
Our code closes the cache when the stream is exhausted; this
is different from the RI which closes it when in.close() is
called.

When a fixed length input stream of length 0 is received,
we cache it immediately. This has behavior consequences for
CONNECT, which needs the otherwise-recyclable connection to
stick around.

This adds explicit shutdown capabilities to MockWebServer.
This is necessary now that we don't guarantee all enqueued
responses will be requested.

We still need test coverage for malformed chunk sizes.

Change-Id: Iaf866af4fc1d76faea559df267a4bde6fdfa1d83
c8977f474b30c5f3807398859a6b16687af6fc7b 15-Jun-2010 Jesse Wilson <jessewilson@google.com> Fixing various problems with HTTPS proxies thru HTTP.

- reading extra bytes from the server depending on available()
- not sending the port with the proxy request
- returning a read-til-the-end stream instead of a read-0-bytes-stream
on CONNECT requests
- fixing MockWebServer to omit the unnecessary \r\n after
the response body
- tests no longer mask the issue by unambiguously reading characters.
Trailing newlines aren't discarded!
- New tests when content-length and content disagree. The RI fails
the test when the transfer-encoding is not chunked.

Change-Id: I888569844d323bc770cd5bb95ac71c740dd5e720
706d53593cd8841d378dbe298a8d1940db1e71df 09-Jun-2010 Jesse Wilson <jessewilson@google.com> Adding HTTPS and proxy support to our mock webserver.

Also exposing core-tests-support for use by tests in frameworks/base.
I'm not particularly happy about this, but it seems to be the best
way to share test support code between the two build targets.

Change-Id: I5e8dcac90fc5d9be791e46c2606498978212108e
b1b5baac449d2725002338735f4db34bec8fd001 08-May-2010 Jesse Wilson <jessewilson@google.com> New MockWebServer for HTTP testing.

Unlike the Support_TestWebServer, this server is dumb but scriptable.
It's intended to make it easier to test uncommon HTTP behavior, such
as an intermediate HTTP proxy.

Change-Id: Iac07e0b4788eeaa172d5c55d8ed9e034d98aa8e6