diff --git a/README.md b/README.md
index e7210539a..e206f237e 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,16 @@
OkHttp
======
-An HTTP+SPDY client for Android and Java applications.
+An HTTP & SPDY client for Android and Java applications.
+
+For more information please see [the website][1].
+
Download
--------
-Download [the latest JAR][1] or grab via Maven:
+Download [the latest JAR][2] or grab via Maven:
```xml
@@ -18,18 +21,6 @@ Download [the latest JAR][1] or grab via Maven:
```
-Known Issues
-------------
-
-OkHttp uses the platform's [ProxySelector][2]. Prior to Android 4.0, `ProxySelector` didn't honor
-the `proxyHost` and `proxyPort` system properties for HTTPS connections. Work around this by
-specifying the `https.proxyHost` and `https.proxyPort` system properties when using a proxy with
-HTTPS.
-
-OkHttp's test suite creates an in-process HTTPS server. Prior to Android 2.3, SSL server sockets
-were broken, and so HTTPS tests will time out when run on such devices.
-
-
Building
--------
@@ -44,6 +35,9 @@ mvn clean test
### On a Device
+OkHttp's test suite creates an in-process HTTPS server. Prior to Android 2.3, SSL server sockets
+were broken, and so HTTPS tests will time out when run on such devices.
+
Test on a USB-attached Android using [Vogar][4]. Unfortunately `dx` requires that you build with
Java 6, otherwise the test class will be silently omitted from the `.dex` file.
@@ -76,7 +70,7 @@ License
- [1]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.squareup.okhttp&a=okhttp&v=LATEST
- [2]: http://developer.android.com/reference/java/net/ProxySelector.html
+ [1]: http://square.github.io/okhttp
+ [2]: http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.squareup.okhttp&a=okhttp&v=LATEST
[3]: http://wiki.eclipse.org/Jetty/Feature/NPN
[4]: https://code.google.com/p/vogar/
diff --git a/okhttp-apache/pom.xml b/okhttp-apache/pom.xml
index d6df7ab40..712fb5e9e 100644
--- a/okhttp-apache/pom.xml
+++ b/okhttp-apache/pom.xml
@@ -23,5 +23,16 @@
httpclient
provided
+
+
+ junit
+ junit
+ test
+
+
+ com.google.mockwebserver
+ mockwebserver
+ test
+
diff --git a/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java b/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java
new file mode 100644
index 000000000..4356d5eec
--- /dev/null
+++ b/okhttp-apache/src/test/java/com/squareup/okhttp/apache/OkApacheClientTest.java
@@ -0,0 +1,71 @@
+package com.squareup.okhttp.apache;
+
+import com.google.mockwebserver.MockResponse;
+import com.google.mockwebserver.MockWebServer;
+import java.io.IOException;
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.junit.After;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class OkApacheClientTest {
+ private MockWebServer server = new MockWebServer();
+ private OkApacheClient client = new OkApacheClient();
+
+ @After public void tearDown() throws IOException {
+ server.shutdown();
+ }
+
+ @Test public void success() throws Exception {
+ server.enqueue(new MockResponse().setBody("Hello, World!"));
+ server.play();
+
+ HttpGet request = new HttpGet(server.getUrl("/").toURI());
+ HttpResponse response = client.execute(request);
+ String actual = EntityUtils.toString(response.getEntity());
+ assertEquals("Hello, World!", actual);
+ }
+
+ @Test public void redirect() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(302).addHeader("Location", "/foo"));
+ server.enqueue(new MockResponse().setBody("Hello, Redirect!"));
+ server.play();
+
+ HttpGet request = new HttpGet(server.getUrl("/").toURI());
+ HttpResponse response = client.execute(request);
+ String actual = EntityUtils.toString(response.getEntity());
+ assertEquals("Hello, Redirect!", actual);
+ }
+
+ @Test public void sessionExpired() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(422));
+ server.play();
+
+ HttpGet request = new HttpGet(server.getUrl("/").toURI());
+ HttpResponse response = client.execute(request);
+ assertEquals(422, response.getStatusLine().getStatusCode());
+ }
+
+ @Test public void headers() throws Exception {
+ server.enqueue(new MockResponse().addHeader("Foo", "Bar"));
+ server.enqueue(new MockResponse().addHeader("Foo", "Bar").addHeader("Foo", "Baz"));
+ server.play();
+
+ HttpGet request1 = new HttpGet(server.getUrl("/").toURI());
+ HttpResponse response1 = client.execute(request1);
+ Header[] headers1 = response1.getHeaders("Foo");
+ assertEquals(1, headers1.length);
+ assertEquals("Bar", headers1[0].getValue());
+
+ HttpGet request2 = new HttpGet(server.getUrl("/").toURI());
+ HttpResponse response2 = client.execute(request2);
+ Header[] headers2 = response2.getHeaders("Foo");
+ assertEquals(2, headers2.length);
+ assertEquals("Bar", headers2[0].getValue());
+ assertEquals("Baz", headers2[1].getValue());
+ }
+}
diff --git a/pom.xml b/pom.xml
index 159b7128c..92e262f78 100644
--- a/pom.xml
+++ b/pom.xml
@@ -146,6 +146,14 @@
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9
+
+ com.squareup.okhttp.internal:com.squareup.okhttp.internal.*
+
+