Skip to content
Snippets Groups Projects
Verified Commit 978028dc authored by Jan-Niclas Strüwer's avatar Jan-Niclas Strüwer
Browse files

store received cookies and reuse them for further requests

parent 47eadfc2
No related branches found
No related tags found
No related merge requests found
Pipeline #27169 canceled
......@@ -8,10 +8,15 @@ import de.fraunhofer.iem.dataprovider.repository.dto.RepositoryCreateDto
import de.fraunhofer.iem.dataprovider.repository.dto.ValidateUserDto
import de.fraunhofer.iem.dataprovider.repository.entity.RepositoryEntity
import de.fraunhofer.iem.dataprovider.repository.repository.RepositoryRepository
import de.fraunhofer.iem.dataprovider.utilities.HttpClientWrapper
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.cookies.*
import io.ktor.client.request.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import kotlinx.serialization.json.Json
import org.springframework.stereotype.Service
import java.util.*
......@@ -19,11 +24,18 @@ import java.util.*
class RepositoryService(
private val repositoryRepository: RepositoryRepository,
private val openCodeGitlabApi: OpenCodeGitlabApi,
private val openCodeApiProperties: OpenCodeApiProperties,
httpClientWrapper: HttpClientWrapper
private val openCodeApiProperties: OpenCodeApiProperties
) {
private val logger = getLogger(javaClass)
private val httpClient = httpClientWrapper.getClient()
private val httpClient = HttpClient(CIO) {
install(HttpCookies)
install(ContentNegotiation) {
json(
Json { ignoreUnknownKeys = true }
)
}
}
/**
* Either creates or returns a repository entity based upon its
* opencode repository id.
......@@ -89,6 +101,17 @@ class RepositoryService(
println(userCookie)
println(userCookie.headers)
println(userCookie.body<Any>())
val setCookies = userCookie.setCookie()
println(setCookies)
val me = httpClient.get(openCodeApiProperties.auth) {
url {
appendPathSegments("me")
}
}
println(me)
println(me.body<Any>())
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.