Merge pull request #737 from i-do-cpp/develop
Support HTTP basic authentication
This commit is contained in:
commit
d9e4b8b3d3
|
@ -8,6 +8,7 @@ import java.security.cert.X509Certificate
|
|||
import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
import javax.net.ssl.SSLContext
|
||||
import javax.net.ssl.X509TrustManager
|
||||
import okhttp3.Credentials
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.ResponseBody
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
|
@ -73,7 +74,19 @@ class SubsonicAPIClient(
|
|||
.addQueryParameter("c", config.clientID)
|
||||
.addQueryParameter("f", "json")
|
||||
.build()
|
||||
chain.proceed(originalRequest.newBuilder().url(newUrl).build())
|
||||
val newRequestBuilder = originalRequest.newBuilder().url(newUrl)
|
||||
if (originalRequest.url.username.isNotEmpty() &&
|
||||
originalRequest.url.password.isNotEmpty()
|
||||
) {
|
||||
newRequestBuilder.addHeader(
|
||||
"Authorization",
|
||||
Credentials.basic(
|
||||
originalRequest.url.username,
|
||||
originalRequest.url.password
|
||||
)
|
||||
)
|
||||
}
|
||||
chain.proceed(newRequestBuilder.build())
|
||||
}
|
||||
.addInterceptor(versionInterceptor)
|
||||
.addInterceptor(proxyPasswordInterceptor)
|
||||
|
|
|
@ -298,7 +298,6 @@ class EditServerFragment : Fragment(), OnBackPressedHandler {
|
|||
url = URL(urlString)
|
||||
if (
|
||||
urlString != urlString.trim(' ') ||
|
||||
urlString.contains("@") ||
|
||||
url.host.isNullOrBlank()
|
||||
) {
|
||||
throw MalformedURLException()
|
||||
|
|
Loading…
Reference in New Issue