Commit 9a334f69 authored by Ricki Hirner's avatar Ricki Hirner

okhttp workaround / connection leaks

* OPTIONS: add Connection-Length: 0 to work around okhttp HTTP/2 error
* fix connection leaks: consume some more response bodies
parent e70f7a41
......@@ -11,10 +11,12 @@ package at.bitfire.dav4android;
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import at.bitfire.dav4android.exception.DavException;
import at.bitfire.dav4android.exception.HttpException;
import lombok.Cleanup;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
......@@ -64,7 +66,9 @@ public class DavAddressBook extends DavResource {
assertMultiStatus(response);
members.clear();
processMultiStatus(response.body().charStream());
@Cleanup Reader reader = response.body().charStream();
processMultiStatus(reader);
}
public void multiget(HttpUrl[] urls, boolean vCard4) throws IOException, HttpException, DavException {
......@@ -110,7 +114,9 @@ public class DavAddressBook extends DavResource {
assertMultiStatus(response);
members.clear();
processMultiStatus(response.body().charStream());
@Cleanup Reader reader = response.body().charStream();
processMultiStatus(reader);
}
}
......@@ -11,6 +11,7 @@ package at.bitfire.dav4android;
import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;
import java.io.Reader;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
......@@ -18,6 +19,7 @@ import java.util.Locale;
import at.bitfire.dav4android.exception.DavException;
import at.bitfire.dav4android.exception.HttpException;
import lombok.Cleanup;
import okhttp3.HttpUrl;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
......@@ -89,7 +91,9 @@ public class DavCalendar extends DavResource {
assertMultiStatus(response);
members.clear();
processMultiStatus(response.body().charStream());
@Cleanup Reader reader = response.body().charStream();
processMultiStatus(reader);
}
public void multiget(HttpUrl[] urls) throws IOException, HttpException, DavException {
......@@ -129,7 +133,9 @@ public class DavCalendar extends DavResource {
assertMultiStatus(response);
members.clear();
processMultiStatus(response.body().charStream());
@Cleanup Reader reader = response.body().charStream();
processMultiStatus(reader);
}
}
......@@ -103,6 +103,7 @@ public class DavResource {
Response response = httpClient.newCall(new Request.Builder()
.method("OPTIONS", null)
.header("Content-Length", "0") // workaround for https://github.com/square/okhttp/issues/2892
.url(location)
.build()).execute();
checkStatus(response, true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment