Upgrade okhttp

This commit is contained in:
len 2016-12-01 19:36:58 +01:00
parent a9b6db9ee9
commit 907472403d
2 changed files with 3 additions and 8 deletions

View File

@ -120,7 +120,7 @@ dependencies {
compile 'com.github.pwittchen:reactivenetwork:0.6.0' compile 'com.github.pwittchen:reactivenetwork:0.6.0'
// Network client // Network client
compile "com.squareup.okhttp3:okhttp:3.4.2" compile "com.squareup.okhttp3:okhttp:3.5.0"
compile 'com.squareup.okio:okio:1.11.0' compile 'com.squareup.okio:okio:1.11.0'
// REST // REST
@ -148,7 +148,7 @@ dependencies {
// Job scheduling // Job scheduling
compile 'com.evernote:android-job:1.1.3' compile 'com.evernote:android-job:1.1.3'
compile 'com.google.android.gms:play-services-gcm:10.0.0' compile 'com.google.android.gms:play-services-gcm:10.0.1'
// Changelog // Changelog
compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0' compile 'com.github.gabrielemariotti.changeloglib:changelog:2.1.0'

View File

@ -12,12 +12,7 @@ import java.util.concurrent.atomic.AtomicBoolean
fun Call.asObservable(): Observable<Response> { fun Call.asObservable(): Observable<Response> {
return Observable.create { subscriber -> return Observable.create { subscriber ->
// Since Call is a one-shot type, clone it for each new subscriber. // Since Call is a one-shot type, clone it for each new subscriber.
val call = if (!isExecuted) this else { val call = clone()
// TODO use clone method in OkHttp 3.5
val field = javaClass.getDeclaredField("client").apply { isAccessible = true }
val client = field.get(this) as OkHttpClient
client.newCall(request())
}
// Wrap the call in a helper which handles both unsubscription and backpressure. // Wrap the call in a helper which handles both unsubscription and backpressure.
val requestArbiter = object : AtomicBoolean(), Producer, Subscription { val requestArbiter = object : AtomicBoolean(), Producer, Subscription {