Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l committed Sep 7, 2021
1 parent ef379e1 commit 4c5a2f6
Show file tree
Hide file tree
Showing 56 changed files with 99 additions and 919 deletions.
20 changes: 10 additions & 10 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ nodejs_version=14.17.1
npm_version=6.4.1
slf4j_version=1.7.30
ktlint_version=3.3.0
mockk_version=1.10.6
mockk_version=1.12.0
mokito_kotlin_version=1.6.0

# typesafe config couldn't be upgraded due to android restrictions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import io.ktor.client.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
import io.ktor.util.*
import io.ktor.util.date.*
import io.ktor.utils.io.*
import io.ktor.utils.io.concurrent.*
import io.ktor.utils.io.core.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
Expand All @@ -20,7 +20,6 @@ internal class SavedHttpCall(client: HttpClient, private val responseBody: ByteA
/**
* Returns a channel with [responseBody] data.
*/
@OptIn(InternalAPI::class)
override suspend fun getResponseContent(): ByteReadChannel {
return ByteReadChannel(responseBody)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package io.ktor.client.engine.mock

import io.ktor.client.engine.*
import io.ktor.client.plugins.*
import io.ktor.client.features.websocket.*
import io.ktor.client.plugins.websocket.*
import io.ktor.client.request.*
import io.ktor.client.utils.*
import io.ktor.util.*
Expand All @@ -21,7 +21,7 @@ public class MockEngine(override val config: MockEngineConfig) : HttpClientEngin
@OptIn(InternalAPI::class)
override val dispatcher: CoroutineDispatcher = Dispatchers.clientDispatcher(config.threadsCount)
override val supportedCapabilities: Set<HttpClientEngineCapability<out Any>> = setOf(
HttpTimeout,
HttpTimeout.Plugin,
WebSocketCapability,
WebSocketExtensionsCapability
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import io.ktor.client.call.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.auth.providers.*
import io.ktor.client.request.*
import io.ktor.client.request.get
import io.ktor.client.statement.*
import io.ktor.client.tests.utils.*
import io.ktor.http.*
import io.ktor.util.*
import io.ktor.utils.io.concurrent.*
import kotlinx.coroutines.*
import kotlin.test.*

Expand Down Expand Up @@ -245,7 +245,7 @@ class AuthTest : ClientLoader() {

test { client ->
client.get("$TEST_SERVER/auth/basic-fixed")
client.post("$TEST_SERVER/auth/basic").let {
client.post("$TEST_SERVER/auth/basic") { expectSuccess = false }.let {
assertEquals(HttpStatusCode.Unauthorized, it.status)
}
}
Expand Down Expand Up @@ -344,7 +344,7 @@ class AuthTest : ClientLoader() {

test { client ->
val response = withContext(Dispatchers.Default) {
client.get<HttpStatement>("$TEST_SERVER/auth/bearer/test-refresh").execute()
client.get("$TEST_SERVER/auth/bearer/test-refresh")
}
assertEquals(HttpStatusCode.OK, response.status)
}
Expand All @@ -363,20 +363,20 @@ class AuthTest : ClientLoader() {
install(Auth) {
bearer {
loadTokens {
val token = clientWithAuth!!.get<String>("$TEST_SERVER/auth/bearer/token/first")
val token = clientWithAuth!!.get("$TEST_SERVER/auth/bearer/token/first").bodyAsText()
BearerTokens(token, token)
}

refreshTokens {
val token = clientWithAuth!!.get<String>("$TEST_SERVER/auth/bearer/token/second")
val token = clientWithAuth!!.get("$TEST_SERVER/auth/bearer/token/second").bodyAsText()
BearerTokens(token, token)
}
}
}
}

val first = clientWithAuth!!.get("$TEST_SERVER/auth/bearer/first").bodyAsText()
val second = clientWithAuth!!.get<String>("$TEST_SERVER/auth/bearer/second")
val second = clientWithAuth!!.get("$TEST_SERVER/auth/bearer/second").bodyAsText()

assertEquals("OK", first)
assertEquals("OK", second)
Expand Down Expand Up @@ -424,9 +424,11 @@ class AuthTest : ClientLoader() {

test { client ->
loadCount = 0
client.get<String>("$TEST_SERVER/auth/bearer/test-refresh")
client.get("$TEST_SERVER/auth/bearer/test-refresh")
.bodyAsText()
client[Auth].providers.filterIsInstance<BearerAuthProvider>().first().clearToken()
client.get<String>("$TEST_SERVER/auth/bearer/test-refresh")
client.get("$TEST_SERVER/auth/bearer/test-refresh")
.bodyAsText()

assertEquals(2, loadCount)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class StethoTracerTest {
val activity = createTestAndroidActivity()
with(activity) {
val client = HttpClient(Stetho(CIO))
val page = runBlocking { client.get<String>("http://www.google.com") }
val page = runBlocking { client.get("http://www.google.com").bodyAsText() }
assertNotNull(page)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ktor-client/ktor-client-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ rootProject.allprojects {
if (!(rootProject.ext.get("native_targets_enabled") as Boolean)) {
return@sourceSets
}
if (ideaActive) {
if (KtorBuildProperties.ideaActive) {
if (name == "posixTest") {
getByName(name) {
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.ktor.client.call.*
import io.ktor.client.engine.mock.*
import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.client.tests.utils.*
import io.ktor.client.utils.*
import io.ktor.http.*
Expand Down Expand Up @@ -203,7 +204,7 @@ class CharsetTest {
}

test { client ->
val response = client.get<String>()
val response = client.get { }.bodyAsText()
assertEquals("Content", response)
}
}
Expand Down Expand Up @@ -231,7 +232,7 @@ class CharsetTest {
}

test { client ->
val response = client.get<String>()
val response = client.get { }.bodyAsText()
assertEquals("Content", response)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ class HeadersTest : ClientLoader() {
@Test
fun testRequestHasContentLength() = clientTests(listOf("Java", "Curl", "Js")) {
test { client ->
val get = client.get<String>("$TEST_SERVER/headers")
val get = client.get("$TEST_SERVER/headers").bodyAsText()
assertEquals("", get)

val head = client.head<String>("$TEST_SERVER/headers")
val head = client.head("$TEST_SERVER/headers").bodyAsText()
assertEquals("", head)

val put = client.put<String>("$TEST_SERVER/headers")
val put = client.put("$TEST_SERVER/headers").bodyAsText()
assertEquals("0", put)

val post = client.post<String>("$TEST_SERVER/headers")
val post = client.post("$TEST_SERVER/headers").bodyAsText()
assertEquals("0", post)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class HttpRedirectTest : ClientLoader() {
}

test { client ->
client.get<HttpStatement>("$TEST_URL_BASE/encodedQuery").execute {
client.prepareGet("$TEST_URL_BASE/encodedQuery").execute {
assertEquals(HttpStatusCode.OK, it.status)
assertEquals("/redirect/getWithUri?key=value1%3Bvalue2%3D%22some=thing", it.readText())
assertEquals("/redirect/getWithUri?key=value1%3Bvalue2%3D%22some=thing", it.bodyAsText())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ class LoggingTest : ClientLoader() {
}

test { client ->
val response = client.request<HttpStatement> {
val response = client.prepareGet {
method = HttpMethod.Get
url("$TEST_SERVER/compression/deflate")
}.receive<String>()
}.body<String>()
assertEquals("Compressed response!", response)
}
after {
Expand All @@ -495,11 +495,11 @@ class LoggingTest : ClientLoader() {
body.close()
}

val response = client.request<HttpStatement> {
val response = client.prepareRequest {
method = HttpMethod.Post
url("$TEST_SERVER/content/echo")
setBody(body)
}.receive<ByteReadChannel>()
}.body<ByteReadChannel>()
response.discard()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.ktor.client.tests

import io.ktor.client.call.*
import io.ktor.client.request.*
import io.ktor.client.tests.utils.*
import io.ktor.content.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import io.ktor.server.routing.*

internal fun Application.tests() {
install(io.ktor.server.websocket.WebSockets) {
maxFrameSize = 4 * 1024
maxFrameSize = 4 * 1024L

extensions {
install(WebSocketDeflateExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ internal fun Application.webSockets() {

webSocket("headers") {
val headers = call.request.headers.toMap()
@OptIn(ExperimentalSerializationApi::class)
val headersJson = Json.encodeToString(headers)
send(Frame.Text(headersJson))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package io.ktor.client.tests

import io.ktor.client.plugins.websocket.*
import io.ktor.client.tests.features.*
import io.ktor.client.tests.utils.*
import io.ktor.http.cio.websocket.*
import kotlin.test.*
Expand All @@ -15,7 +14,7 @@ private const val TEST_SIZE: Int = 100
class WebSocketJvmTest : ClientLoader(100000) {

@Test
fun testWebSocketDeflateBinary() = clientTests(ENGINES_WITHOUT_WS_EXTENSIONS) {
fun testWebSocketDeflateBinary() = clientTests(listOf("Android", "Apache")) {
config {
WebSockets {
extensions {
Expand All @@ -39,7 +38,7 @@ class WebSocketJvmTest : ClientLoader(100000) {
}

@Test
fun testWebSocketDeflateNoContextTakeover() = clientTests(ENGINES_WITHOUT_WS_EXTENSIONS) {
fun testWebSocketDeflateNoContextTakeover() = clientTests(listOf("Android", "Apache")) {
config {
WebSockets {
extensions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ class InvalidMutabilityExceptionTest : ClientLoader() {
test { client ->
val cause = assertFails {
val response = withContext(Dispatchers.Default) {
client.get<HttpResponse>("$TEST_SERVER/content/hello")
client.get("$TEST_SERVER/content/hello")
}
response.readText()
response.bodyAsText()
}

assertIs<IllegalStateException>(cause)
Expand Down
10 changes: 0 additions & 10 deletions ktor-io/common/src/io/ktor/utils/io/core/BytePacketBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@ package io.ktor.utils.io.core
import io.ktor.utils.io.bits.*
import io.ktor.utils.io.core.internal.*
import io.ktor.utils.io.pool.*
import kotlin.Boolean
import kotlin.Char
import kotlin.CharSequence
import kotlin.Deprecated
import kotlin.DeprecationLevel
import kotlin.Int
import kotlin.PublishedApi
import kotlin.String
import kotlin.Suppress
import kotlin.jvm.*

/**
* A builder that provides ability to build byte packets with no knowledge of it's size.
Expand Down
8 changes: 3 additions & 5 deletions ktor-io/js/src/io/ktor/utils/io/charsets/CharsetJS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,14 @@ public actual abstract class Charset(internal val _name: String) {
@Suppress("LocalVariableName")
public actual fun forName(name: String): Charset {
if (name == "UTF-8" || name == "utf-8" || name == "UTF8" || name == "utf8") return Charsets.UTF_8
if (name == "ISO-8859-1" || name == "iso-8859-1" ||
name.replace('_', '-').let { it == "iso-8859-1" || it.toLowerCase() == "iso-8859-1" } ||
name == "latin1" || name == "Latin1"
if (name == "ISO-8859-1" || name == "iso-8859-1"
|| name.replace('_', '-').let { it == "iso-8859-1" || it.toLowerCase() == "iso-8859-1" }
|| name == "latin1" || name == "Latin1"
) {
return Charsets.ISO_8859_1
}
throw IllegalArgumentException("Charset $name is not supported")
}
}
}

public actual fun isSupported(charset: String): Boolean = when {
charset == "UTF-8" || charset == "utf-8" || charset == "UTF8" || charset == "utf8" -> true
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package io.ktor.network.tls

import io.ktor.util.*
import io.ktor.utils.io.core.*

@Suppress("KDocMissingDocumentation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ internal class TLSClientHandshake(
}
}

public suspend fun negotiate() {
suspend fun negotiate() {
digest.use {
sendClientHello()
serverHello = receiveServerHello()
Expand Down Expand Up @@ -377,8 +377,9 @@ internal class TLSClientHandshake(

if (hasHashAndSignInCommon) return@find false

info.authorities.isEmpty() ||
candidate.certificateChain.map { X500Principal(it.issuerDN.name) }.any { it in info.authorities }
info.authorities.isEmpty() || candidate.certificateChain
.map { X500Principal(it.issuerX500Principal.name) }
.any { it in info.authorities }
}

sendHandshakeRecord(TLSHandshakeType.Certificate) {
Expand Down
Loading

0 comments on commit 4c5a2f6

Please sign in to comment.