Subscription support http basic authentication in url.

This commit is contained in:
tiou
2021-08-23 16:49:35 +08:00
parent e9d2ed98af
commit e257c4cb56

View File

@@ -459,10 +459,15 @@ object Utils {
}
@Throws(IOException::class)
fun getUrlContentWithCustomUserAgent(url: String?): String {
val conn = URL(url).openConnection()
fun getUrlContentWithCustomUserAgent(urlStr: String?): String {
val url = URL(urlStr)
val conn = url.openConnection()
conn.setRequestProperty("Connection", "close")
conn.setRequestProperty("User-agent", "v2rayNG/${BuildConfig.VERSION_NAME}")
url.userInfo?.let {
conn.setRequestProperty("Authorization",
"Basic ${encode(URLDecoder.decode(it,"UTF-8"))}")
}
conn.useCaches = false
return conn.inputStream.use {
it.bufferedReader().readText()