Support SSE for source updates #197

Open
davidoskky wants to merge 2 commits from davidoskky/ReaderForSelfoss-multiplatform:source-update into master

View File

@ -19,6 +19,7 @@ import io.ktor.client.plugins.cookies.HttpCookies
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
import io.ktor.client.plugins.logging.Logging
import io.ktor.client.plugins.sse.SSE
import io.ktor.client.request.get
import io.ktor.client.request.headers
import io.ktor.client.request.parameter
@ -89,6 +90,7 @@ class SelfossApi(
}
}
}
install(SSE)
expectSuccess = false
}
@ -363,26 +365,11 @@ class SelfossApi(
suspend fun update(): StatusAndData<String> =
bodyOrFailure(
client.tryToGet(url("/update")) {
if (!shouldHavePostLogin()) {
parameter("username", appSettingsService.getUserName())
parameter("password", appSettingsService.getPassword())
}
if (appSettingsService
.getBasicUserName()
.isNotEmpty() &&
appSettingsService.getBasicPassword().isNotEmpty()
) {
headers {
append(
HttpHeaders.Authorization,
constructBasicAuthValue(
BasicAuthCredentials(
username = appSettingsService.getBasicUserName(),
password = appSettingsService.getBasicPassword(),
),
),
)
}
headers {
append(
HttpHeaders.Accept,
"text/event-stream",
)
}
},
)