mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
Merge branch 'master' of github.com:gedoor/legado
This commit is contained in:
commit
7abc2773e4
@ -71,8 +71,8 @@ android {
|
||||
}
|
||||
applicationIdSuffix '.release'
|
||||
|
||||
minifyEnabled true
|
||||
shrinkResources true
|
||||
minifyEnabled false
|
||||
//shrinkResources true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
debug {
|
||||
|
@ -49,6 +49,7 @@ abstract class AbsCallBack(
|
||||
private var cancelJob: Coroutine<*>? = null
|
||||
private var followRedirect = false
|
||||
private var enableCookieJar = false
|
||||
private var redirectRequest: Request? = null
|
||||
|
||||
init {
|
||||
if (originalRequest.header(cookieJarHeader) != null) {
|
||||
@ -108,7 +109,7 @@ abstract class AbsCallBack(
|
||||
if (enableCookieJar) {
|
||||
CookieManager.saveResponse(response)
|
||||
}
|
||||
originalRequest = buildRedirectRequest(response, originalRequest.method, newLocationUrl)
|
||||
redirectRequest = buildRedirectRequest(response, originalRequest.method, newLocationUrl)
|
||||
}
|
||||
request.cancel()
|
||||
}
|
||||
@ -189,10 +190,10 @@ abstract class AbsCallBack(
|
||||
if (followRedirect) {
|
||||
followRedirect = false
|
||||
if (enableCookieJar) {
|
||||
val newRequest = CookieManager.loadRequest(originalRequest)
|
||||
val newRequest = CookieManager.loadRequest(redirectRequest!!)
|
||||
buildRequest(newRequest, this)?.start()
|
||||
} else {
|
||||
buildRequest(originalRequest, this)?.start()
|
||||
buildRequest(redirectRequest!!, this)?.start()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import com.bumptech.glide.util.ContentLengthInputStream
|
||||
import com.bumptech.glide.util.Preconditions
|
||||
import io.legado.app.data.entities.BaseSource
|
||||
import io.legado.app.exception.NoStackTraceException
|
||||
import io.legado.app.help.http.CookieManager.cookieJarHeader
|
||||
import io.legado.app.help.http.addHeaders
|
||||
import io.legado.app.help.http.okHttpClient
|
||||
import io.legado.app.help.source.SourceHelp
|
||||
@ -56,6 +57,9 @@ class OkHttpStreamFetcher(private val url: GlideUrl, private val options: Option
|
||||
source?.getHeaderMap(true)?.let {
|
||||
headerMap.putAll(it)
|
||||
}
|
||||
if (source?.enabledCookieJar == true) {
|
||||
headerMap[cookieJarHeader] = "1"
|
||||
}
|
||||
}
|
||||
headerMap.putAll(url.headers)
|
||||
requestBuilder.addHeaders(headerMap)
|
||||
|
@ -67,7 +67,7 @@ val okHttpClient: OkHttpClient by lazy {
|
||||
builder.addHeader("Keep-Alive", "300")
|
||||
builder.addHeader("Connection", "Keep-Alive")
|
||||
builder.addHeader("Cache-Control", "no-cache")
|
||||
chain.proceed(builder.build()).newBuilder().removeHeader(cookieJarHeader).build()
|
||||
chain.proceed(builder.build())
|
||||
})
|
||||
.addNetworkInterceptor { chain ->
|
||||
var request = chain.request()
|
||||
@ -79,11 +79,10 @@ val okHttpClient: OkHttpClient by lazy {
|
||||
request = CookieManager.loadRequest(requestBuilder.build())
|
||||
}
|
||||
|
||||
var networkResponse = chain.proceed(request)
|
||||
val networkResponse = chain.proceed(request)
|
||||
|
||||
if (enableCookieJar) {
|
||||
CookieManager.saveResponse(networkResponse)
|
||||
networkResponse = networkResponse.newBuilder().header(cookieJarHeader, "1").build()
|
||||
}
|
||||
networkResponse
|
||||
}
|
||||
|
@ -376,10 +376,6 @@ class ObsoleteUrlFactory(private var client: OkHttpClient) : URLStreamHandlerFac
|
||||
val clientBuilder: OkHttpClient.Builder = client.newBuilder()
|
||||
clientBuilder.interceptors().clear()
|
||||
clientBuilder.interceptors().add(UnexpectedException.INTERCEPTOR)
|
||||
clientBuilder.addInterceptor { chain ->
|
||||
val response = chain.proceed(chain.request())
|
||||
response.newBuilder().removeHeader(cookieJarHeader).build()
|
||||
}
|
||||
|
||||
clientBuilder.networkInterceptors().clear()
|
||||
clientBuilder.networkInterceptors().add(networkInterceptor)
|
||||
@ -393,13 +389,10 @@ class ObsoleteUrlFactory(private var client: OkHttpClient) : URLStreamHandlerFac
|
||||
request1 = CookieManager.loadRequest(requestBuilder.build())
|
||||
}
|
||||
|
||||
var networkResponse = chain.proceed(request1)
|
||||
val networkResponse = chain.proceed(request1)
|
||||
|
||||
if (enableCookieJar) {
|
||||
CookieManager.saveResponse(networkResponse)
|
||||
networkResponse = networkResponse.newBuilder()
|
||||
.header(cookieJarHeader, "1")
|
||||
.build()
|
||||
}
|
||||
networkResponse
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user