Skip to content

Commit 4333105

Browse files
committed
fix(network): force HTTP/1.1 to avoid broken HTTP/2 streams
Some sources (e.g. chikari.moe) advertise HTTP/2 but reset the stream (RST_STREAM/CANCEL) mid-response, crashing the whole request with StreamResetException. Force HTTP/1.1 on the scraper client so these servers respond normally. The DoH client is left untouched.
1 parent 939facb commit 4333105

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

networking/src/main/java/my/noveldokusha/network/NetworkClient.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import okhttp3.ConnectionPool
1313
import okhttp3.Dispatcher
1414
import okhttp3.Dns
1515
import okhttp3.OkHttpClient
16+
import okhttp3.Protocol
1617
import okhttp3.Request
1718
import okhttp3.Response
1819
import java.io.File
@@ -61,6 +62,10 @@ class ScraperNetworkClient @Inject constructor(
6162
cache(Cache(cacheDir, cacheSize))
6263
connectTimeout(30, TimeUnit.SECONDS)
6364
readTimeout(30, TimeUnit.SECONDS)
65+
// Форсим HTTP/1.1: часть сторонних источников (напр. chikari.moe) заявляет
66+
// HTTP/2, но рвёт стрим (RST_STREAM/CANCEL) посреди тела ответа. OkHttp это
67+
// не переживает — падает весь запрос. На HTTP/1.1 сервер отрабатывает нормально.
68+
protocols(listOf(Protocol.HTTP_1_1))
6469
// Кастомный DNS resolver через DoH — работает когда системный DNS блокируется Doze mode
6570
dns(DnsOverHttps())
6671
}

0 commit comments

Comments
 (0)