Subscription support http basic authentication in url.
This commit is contained in:
@@ -459,10 +459,15 @@ object Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class)
|
@Throws(IOException::class)
|
||||||
fun getUrlContentWithCustomUserAgent(url: String?): String {
|
fun getUrlContentWithCustomUserAgent(urlStr: String?): String {
|
||||||
val conn = URL(url).openConnection()
|
val url = URL(urlStr)
|
||||||
|
val conn = url.openConnection()
|
||||||
conn.setRequestProperty("Connection", "close")
|
conn.setRequestProperty("Connection", "close")
|
||||||
conn.setRequestProperty("User-agent", "v2rayNG/${BuildConfig.VERSION_NAME}")
|
conn.setRequestProperty("User-agent", "v2rayNG/${BuildConfig.VERSION_NAME}")
|
||||||
|
url.userInfo?.let {
|
||||||
|
conn.setRequestProperty("Authorization",
|
||||||
|
"Basic ${encode(URLDecoder.decode(it,"UTF-8"))}")
|
||||||
|
}
|
||||||
conn.useCaches = false
|
conn.useCaches = false
|
||||||
return conn.inputStream.use {
|
return conn.inputStream.use {
|
||||||
it.bufferedReader().readText()
|
it.bufferedReader().readText()
|
||||||
|
|||||||
Reference in New Issue
Block a user