├── .gitignore
├── README.md
├── browser
├── build.gradle
└── src
│ ├── main
│ └── kotlin
│ │ └── io
│ │ └── ktor
│ │ └── common
│ │ └── client
│ │ ├── JsHttpClient.kt
│ │ └── JsUtils.kt
│ └── test
│ └── kotlin
│ └── io
│ └── ktor
│ └── common
│ └── client
│ └── JsTests.kt
├── build.gradle
├── common
├── build.gradle
└── src
│ ├── main
│ └── kotlin
│ │ └── io
│ │ └── ktor
│ │ └── common
│ │ └── client
│ │ ├── Builders.kt
│ │ ├── HttpClient.kt
│ │ ├── HttpRequest.kt
│ │ ├── HttpResponse.kt
│ │ ├── http
│ │ ├── HttpMethod.kt
│ │ ├── Parameters.kt
│ │ ├── URLProtocol.kt
│ │ └── Url.kt
│ │ └── utils.kt
│ └── test
│ └── kotlin
│ └── io
│ └── ktor
│ └── common
│ └── client
│ └── RequestTests.kt
├── gradle.properties
├── gradle
├── publish.gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── ios
├── build.gradle
└── src
│ └── main
│ └── kotlin
│ ├── NativeHttpClient.kt
│ ├── NativeUtils.kt
│ └── iphone.kt
├── jvm
├── build.gradle
└── src
│ ├── main
│ └── kotlin
│ │ └── io
│ │ └── ktor
│ │ └── common
│ │ └── client
│ │ ├── JvmHttpClient.kt
│ │ └── JvmUtils.kt
│ └── test
│ └── kotlin
│ └── io
│ └── ktor
│ └── common
│ └── client
│ └── JvmTests.kt
├── samples
├── android-test-application
│ ├── .gitignore
│ ├── .idea
│ │ ├── caches
│ │ │ └── build_file_checksums.ser
│ │ ├── codeStyles
│ │ │ └── Project.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ └── runConfigurations.xml
│ ├── app
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ ├── androidTest
│ │ │ └── java
│ │ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── jetbrains
│ │ │ │ └── android_test_application
│ │ │ │ └── ExampleInstrumentedTest.kt
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ │ └── com
│ │ │ │ │ └── example
│ │ │ │ │ └── jetbrains
│ │ │ │ │ └── android_test_application
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ │ ├── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ │ └── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── styles.xml
│ │ │ └── test
│ │ │ └── java
│ │ │ └── com
│ │ │ └── example
│ │ │ └── jetbrains
│ │ │ └── android_test_application
│ │ │ └── ExampleUnitTest.kt
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios-test-application
│ ├── .idea
│ │ ├── codeStyles
│ │ │ └── Project.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ ├── workspace.xml
│ │ └── xcode.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── ios-test-application.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ ├── xcshareddata
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcuserdata
│ │ │ │ ├── jetbrains.xcuserdatad
│ │ │ │ ├── UserInterfaceState.xcuserstate
│ │ │ │ └── xcschemes
│ │ │ │ │ └── xcschememanagement.plist
│ │ │ │ └── leonid.xcuserdatad
│ │ │ │ └── UserInterfaceState.xcuserstate
│ │ └── xcuserdata
│ │ │ ├── jetbrains.xcuserdatad
│ │ │ └── xcschemes
│ │ │ │ ├── ios-test-application.xcscheme
│ │ │ │ └── xcschememanagement.plist
│ │ │ └── leonid.xcuserdatad
│ │ │ └── xcschemes
│ │ │ ├── ios-test-application.xcscheme
│ │ │ └── xcschememanagement.plist
│ ├── ios-test-application
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── Base.lproj
│ │ │ ├── LaunchScreen.storyboard
│ │ │ └── Main.storyboard
│ │ ├── Info.plist
│ │ ├── ViewController.h
│ │ ├── ViewController.m
│ │ └── main.m
│ ├── settings.gradle
│ └── src
│ │ └── main
│ │ └── kotlin
│ │ └── main.kt
└── web-test-application
│ ├── .idea
│ ├── codeStyles
│ │ └── codeStyleConfig.xml
│ ├── gradle.xml
│ ├── kotlinc.xml
│ ├── misc.xml
│ ├── usage.statistics.xml
│ ├── vcs.xml
│ └── workspace.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ ├── package.json
│ ├── src
│ └── main
│ │ ├── js
│ │ └── index.js
│ │ ├── kotlin
│ │ └── io
│ │ │ └── ktor
│ │ │ └── common
│ │ │ └── client
│ │ │ └── test.kt
│ │ └── web
│ │ └── index.html
│ ├── webpack.common.js
│ ├── webpack.config.js
│ └── webpack.dev.js
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | .gradle
4 | .externalNativeBuild
5 | local.properties
6 |
7 | .idea/*
8 | *.iml
9 |
10 | build
11 | out
12 |
13 | node_modules
14 | *.log
15 | package-lock.json
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # http-client-common
2 |
3 | ## *DEPRECATION NOTICE*
4 | This repository is outdated. Multiplatform client is included in [ktor](http://ktor.io) from version from `0.9.4`.
5 |
6 | Updated samples located here: https://github.com/ktorio/ktor-samples/tree/master/mpp/client-mpp
7 |
8 | ## Description
9 |
10 | Kotlin multiplatform http client
11 |
12 | ```kotlin
13 | val client = HttpClient()
14 |
15 | promise {
16 | client.request {
17 | url.apply {
18 | protocol = URLProtocol.HTTPS
19 | host = "https://en.wikipedia.org"
20 | encodedPath = "/wiki/Kotlin_(programming_language)"
21 | port = 443
22 | }
23 | }
24 | }.then {
25 | println(it.body)
26 | }
27 | ```
28 |
29 | ## Dependencies
30 |
31 | 1. Kotlin native compiler version: 0.8
32 |
33 | ### Gradle
34 | ```groovy
35 | buildscript {
36 | ext.http_client_version = '0.1.15'
37 | }
38 |
39 | repositories {
40 | maven { url 'https://dl.bintray.com/e5l/http-client-common' }
41 | }
42 |
43 | dependencies {
44 | // common
45 | compile "io.ktor.common.client:common:$http_client_version"
46 |
47 | // javascript(browser)
48 | compile "io.ktor.common.client:browser:$http_client_version"
49 |
50 | // jvm + android
51 | compile "io.ktor.common.client:jvm:$http_client_version"
52 |
53 | // ios
54 | implementation "io.ktor.common.client:ios:$http_client_version"
55 | }
56 | ```
57 |
58 | ```groovy
59 | // enable gradle metadata in settings.gradle
60 | enableFeaturePreview('GRADLE_METADATA')
61 | ```
62 |
63 | ## Samples
64 | 1. [ios](samples/ios-test-application)
65 | 2. [android](samples/android-test-application)
66 | 3. [js(browser)](samples/web-test-application)
67 |
--------------------------------------------------------------------------------
/browser/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.moowork.node'
2 |
3 | dependencies {
4 | expectedBy project(":common")
5 | compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
6 | compile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
7 | compile "org.jetbrains.kotlinx:kotlinx-coroutines-core-js:$coroutines_version"
8 | testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
9 | }
10 |
11 | [compileKotlin2Js, compileTestKotlin2Js]*.configure {
12 | kotlinOptions {
13 | sourceMap = true
14 | sourceMapEmbedSources = 'always'
15 | moduleKind = 'umd'
16 | }
17 | }
18 |
19 | task populateNodeModules(type: Copy, dependsOn: compileKotlin2Js) {
20 | from compileKotlin2Js.destinationDir
21 |
22 | configurations.testCompile.each {
23 | from zipTree(it.absolutePath).matching { include '*.js' }
24 | }
25 |
26 | into "${buildDir}/node_modules"
27 | }
28 |
29 | task installDependenciesMochaChrome(type: NpmTask) {
30 | args = ['install', 'mocha', 'mocha-headless-chrome', "kotlin", "kotlin-test", 'kotlinx-coroutines-core', '--no-save']
31 | }
32 |
33 | task prepareMochaChrome(dependsOn: [compileTestKotlin2Js, populateNodeModules, installDependenciesMochaChrome])
34 |
35 | prepareMochaChrome.doLast {
36 | file("$buildDir/test-page.html").text = """
37 |
38 |
39 |
40 | Mocha Tests
41 |
42 |
43 |
44 |
45 |
46 |
47 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | """
61 | }
62 |
63 | task testMochaChrome(type: NodeTask, dependsOn: prepareMochaChrome) {
64 | script = file('node_modules/mocha-headless-chrome/bin/start')
65 | args = [compileTestKotlin2Js.outputFile, '--file', "$buildDir/test-page.html"]
66 | }
67 |
68 | testClasses.dependsOn populateNodeModules
69 |
70 | test.dependsOn testMochaChrome
71 |
72 | // clean
73 | task deleteNodeModules(type: Delete) {
74 | delete 'node_modules'
75 | delete 'package-lock.json'
76 | }
77 |
78 | kotlin.experimental.coroutines 'enable'
79 |
80 | clean.dependsOn deleteNodeModules
81 |
--------------------------------------------------------------------------------
/browser/src/main/kotlin/io/ktor/common/client/JsHttpClient.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlinx.coroutines.experimental.*
4 | import org.w3c.fetch.*
5 | import kotlin.browser.*
6 |
7 | actual class HttpClient actual constructor() : Closeable {
8 | actual suspend fun request(request: HttpRequest): HttpResponse = HttpResponseBuilder(request).apply {
9 | val response = fetch(request)
10 | statusCode = response.status.toInt()
11 | headers.putAll(response.headers.entries())
12 | body = response.receiveBody()
13 | }.build()
14 |
15 | override fun close() {
16 | }
17 | }
18 |
19 | private suspend fun Response.receiveBody(): String = suspendCancellableCoroutine { continuation ->
20 | text().then { continuation.resume(it) }
21 | }
22 |
23 | private suspend fun fetch(request: HttpRequest): Response = suspendCancellableCoroutine { continuation ->
24 | val headers = js("({})")
25 | request.headers.forEach { (key, values) ->
26 | headers[key] = values
27 | }
28 |
29 | val rawRequest = js("({})")
30 | rawRequest["method"] = request.method.value
31 | rawRequest["headers"] = headers
32 | request.body?.let { rawRequest["body"] = it }
33 |
34 | window.fetch(request.url.build(), rawRequest as RequestInit).then { continuation.resume(it) }
35 | }
36 |
37 | private fun Headers.entries(): Map> {
38 | val result = mutableMapOf>()
39 |
40 | asDynamic().forEach { value, key ->
41 | result[key as String] = listOf(value as String)
42 | Unit
43 | }
44 |
45 | return result
46 | }
47 |
--------------------------------------------------------------------------------
/browser/src/main/kotlin/io/ktor/common/client/JsUtils.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlinx.coroutines.experimental.*
4 |
5 | actual fun promise(block: suspend () -> T): Promise {
6 | val result = async {
7 | block()
8 | }
9 |
10 | return Promise().also {
11 | result.invokeOnCompletion { cause ->
12 | if (cause == null) {
13 | it.complete(result.getCompleted())
14 | } else {
15 | it.completeWithException(cause)
16 | }
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/browser/src/test/kotlin/io/ktor/common/client/JsTests.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlinx.coroutines.experimental.*
4 | import kotlin.js.*
5 | import kotlin.test.*
6 |
7 | class JsTests {
8 | @Test
9 | fun testGet(): Promise = promise {
10 | RequestTests.testGet()
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
4 | maven { url 'https://plugins.gradle.org/m2/' }
5 | maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
6 | maven { url 'https://maven.google.com' }
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
12 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
13 | classpath "com.android.tools.build:gradle:$gradle_android_version"
14 | classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_plugin_version"
15 | }
16 | }
17 |
18 | static def platformOf(project) {
19 | if (project.name.endsWith('common')) return 'common'
20 | if (project.name.endsWith('browser')) return 'js'
21 | if (project.name.endsWith('native')) return 'native'
22 | if (project.name.endsWith('ios')) return 'native'
23 | if (project.name.endsWith('jvm')) return 'jvm'
24 | return 'common'
25 | }
26 |
27 | def libs = ['common', 'jvm', 'ios', 'browser']
28 | configure(subprojects.findAll { libs.contains(it.name) }) {
29 | def platform = platformOf(project)
30 |
31 | group 'io.ktor.common.client'
32 | version '0.1.15'
33 |
34 | repositories {
35 | maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
36 | maven { url 'https://kotlin.bintray.com/kotlinx' }
37 | maven { url 'https://maven.google.com' }
38 | jcenter()
39 | }
40 |
41 | apply plugin: "kotlin-platform-$platform"
42 | if (platform != 'native') {
43 | kotlin.experimental.coroutines 'enable'
44 | }
45 |
46 | apply plugin: 'maven'
47 | apply plugin: 'maven-publish'
48 | apply plugin: 'com.jfrog.bintray'
49 |
50 | tasks.withType(Test) {
51 | testLogging {
52 | showStandardStreams = true
53 | events 'passed', 'failed'
54 | }
55 | }
56 | }
57 |
58 | configure(subprojects.findAll { libs.contains(it.name) }) { project ->
59 | apply from: rootProject.file('gradle/publish.gradle')
60 | }
61 |
--------------------------------------------------------------------------------
/common/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | dependencies {
3 | compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
4 | testCompile "org.jetbrains.kotlin:kotlin-test-annotations-common:$kotlin_version"
5 | testCompile "org.jetbrains.kotlin:kotlin-test-common:$kotlin_version"
6 | }
7 |
8 | kotlin.experimental.coroutines 'enable'
9 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/Builders.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | /**
4 | * Execute [HttpRequest] from [block]
5 | */
6 | suspend fun HttpClient.request(block: HttpRequestBuilder.() -> Unit): HttpResponse =
7 | request(HttpRequestBuilder().apply(block).build())
8 |
9 | suspend fun HttpClient.request(host: String): HttpResponse = request(HttpRequestBuilder().apply {
10 | url.host = host
11 | }.build())
12 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/HttpClient.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | expect class HttpClient() : Closeable {
4 | suspend fun request(request: HttpRequest): HttpResponse
5 | }
6 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/HttpRequest.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import io.ktor.common.client.http.*
4 |
5 | class HttpRequest(
6 | val url: URLBuilder,
7 | val method: HttpMethod,
8 | val headers: Map>,
9 | val body: String?
10 | )
11 |
12 | class HttpRequestBuilder {
13 | val url: URLBuilder = URLBuilder()
14 | var method: HttpMethod = HttpMethod.Get
15 | var body: String? = null
16 | var headers: MutableMap> = mutableMapOf()
17 |
18 | fun build(): HttpRequest = HttpRequest(url, method, headers, body)
19 | }
20 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/HttpResponse.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | class HttpResponse(
4 | val statusCode: Int,
5 | val headers: Map>,
6 | val body: String,
7 | val request: HttpRequest
8 | )
9 |
10 | class HttpResponseBuilder(val request: HttpRequest) {
11 | var statusCode: Int = -1
12 | var headers: MutableMap> = mutableMapOf()
13 | var body = ""
14 |
15 | fun build(): HttpResponse = HttpResponse(statusCode, headers, body, request)
16 | }
17 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/http/HttpMethod.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client.http
2 |
3 | data class HttpMethod(val value: String) {
4 | companion object {
5 | val Get = HttpMethod("GET")
6 | val Post = HttpMethod("POST")
7 | val Put = HttpMethod("PUT")
8 | val Patch = HttpMethod("PATCH")
9 | val Delete = HttpMethod("DELETE")
10 | val Head = HttpMethod("HEAD")
11 | val Options = HttpMethod("OPTIONS")
12 |
13 | fun parse(method: String): HttpMethod {
14 | return when (method) {
15 | Get.value -> Get
16 | Post.value -> Post
17 | Put.value -> Put
18 | Patch.value -> Patch
19 | Delete.value -> Delete
20 | Head.value -> Head
21 | Options.value -> Options
22 | else -> HttpMethod(method)
23 | }
24 | }
25 |
26 | val DefaultMethods = listOf(Get, Post, Put, Patch, Delete, Head, Options)
27 | }
28 | }
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/http/Parameters.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client.http
2 |
3 | typealias Parameters = Map
4 | typealias ParametersBuilder = MutableMap
5 |
6 | fun encodeURLQueryComponent(component: String): String = component // URLEncoder.encode(s, Charsets.UTF_8.name())
7 |
8 | fun Parameters.formUrlEncodeTo(out: Appendable) {
9 | entries.map { (key, value) -> key to value }.formUrlEncodeTo(out)
10 | }
11 |
12 | fun List>.formUrlEncodeTo(out: Appendable) {
13 | joinTo(out, "&") {
14 | "${encodeURLQueryComponent(it.first)}=${encodeURLQueryComponent(it.second)}"
15 | }
16 | }
17 |
18 | fun encodeURLPart(part: String): String = encodeURLQueryComponent(part)
19 | .replace("+", "%20")
20 | .replace("%2b", "+")
21 | .replace("%2B", "+")
22 | .replace("*", "%2A")
23 | .replace("%7E", "~")
24 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/http/URLProtocol.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client.http
2 |
3 | data class URLProtocol(val name: String, val defaultPort: Int) {
4 | companion object {
5 | val HTTP = URLProtocol("http", 80)
6 | val HTTPS = URLProtocol("https", 443)
7 | val WS = URLProtocol("ws", 80)
8 | val WSS = URLProtocol("wss", 443)
9 |
10 | val byName = listOf(HTTP, HTTPS, WS, WSS).associateBy { it.name }
11 |
12 | fun createOrDefault(name: String): URLProtocol = name.toLowerCase().let {
13 | byName[it] ?: URLProtocol(it, -1)
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/http/Url.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client.http
2 |
3 | class URLBuilder(
4 | var protocol: URLProtocol = URLProtocol.HTTP,
5 | var host: String = "localhost",
6 | var port: Int = protocol.defaultPort,
7 | var user: String? = null,
8 | var password: String? = null,
9 | var encodedPath: String = "/",
10 | val parameters: ParametersBuilder = mutableMapOf(),
11 | var fragment: String = "",
12 | var trailingQuery: Boolean = false
13 | ) {
14 | fun path(vararg components: String) {
15 | path(components.asList())
16 | }
17 |
18 | fun path(components: List) {
19 | encodedPath = components.joinToString("/", prefix = "/") { encodeURLPart(it) }
20 | }
21 |
22 | private fun appendTo(out: A): A {
23 | out.append(protocol.name)
24 | out.append("://")
25 | user?.let { usr ->
26 | out.append(encodeURLPart(usr))
27 | password?.let { pwd ->
28 | out.append(":")
29 | out.append(encodeURLPart(pwd))
30 | }
31 | out.append("@")
32 | }
33 | out.append(host)
34 |
35 | if (port != protocol.defaultPort) {
36 | out.append(":")
37 | out.append(port.toString())
38 | }
39 |
40 | if (!encodedPath.startsWith("/")) {
41 | out.append('/')
42 | }
43 |
44 | out.append(encodedPath)
45 |
46 | val queryParameters = parameters
47 | if (!queryParameters.isEmpty() || trailingQuery) {
48 | out.append("?")
49 | }
50 |
51 | queryParameters.formUrlEncodeTo(out)
52 |
53 | if (fragment.isNotEmpty()) {
54 | out.append('#')
55 | out.append(encodeURLPart(fragment))
56 | }
57 |
58 | return out
59 | }
60 |
61 | fun build(): String = appendTo(StringBuilder(256)).toString()
62 |
63 | override fun toString() = build()
64 |
65 | companion object
66 | }
67 |
--------------------------------------------------------------------------------
/common/src/main/kotlin/io/ktor/common/client/utils.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | interface Closeable {
4 | fun close()
5 | }
6 |
7 | inline fun T.use(block: (T) -> R): R = try {
8 | block(this)
9 | } finally {
10 | close()
11 | }
12 |
13 | typealias ErrorHandler = (Throwable) -> Unit
14 |
15 | class Promise {
16 | private var handler: (T) -> Unit = {}
17 | private var errorHandler: ErrorHandler = {}
18 |
19 | fun complete(result: T) {
20 | handler(result)
21 | }
22 |
23 | fun completeWithException(exception: Throwable) {
24 | errorHandler(exception)
25 | }
26 |
27 | fun then(block: (T) -> Unit): Promise {
28 | handler = block
29 | return this
30 | }
31 |
32 | fun catch(errHandler: ErrorHandler): Promise {
33 | errorHandler = errHandler
34 | return this
35 | }
36 | }
37 |
38 | expect fun promise(block: suspend () -> T): Promise
39 |
--------------------------------------------------------------------------------
/common/src/test/kotlin/io/ktor/common/client/RequestTests.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import io.ktor.common.client.http.*
4 |
5 | object RequestTests {
6 | private val HEADER = "---==="
7 |
8 | suspend fun testGet() {
9 | println("$HEADER start testGet")
10 | val client = HttpClient()
11 | val response = client.request {
12 | url.apply {
13 | protocol = URLProtocol.HTTPS
14 | host = "cors-anywhere.herokuapp.com"
15 | encodedPath = "/google.ru"
16 | port = 443
17 | }
18 | }
19 | println("$HEADER request: ${response.request.url}")
20 | println("$HEADER response status: ${response.statusCode}")
21 | println("$HEADER headers:")
22 | response.headers.forEach { (key, values) ->
23 | println(" -$key: ${values.joinToString()}")
24 | }
25 | println("$HEADER body:")
26 | println(response.body.take(300))
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin_version = 1.2.51
2 | kotlin_native_version = 0.8
3 | kotlin.incremental.multiplatform=true
4 | bintray_plugin_version = 1.8.2-SNAPSHOT
5 |
6 | ktor_version = 0.9.3-alpha-5
7 |
8 | node_version = 8.9.3
9 | npm_version = 5.5.1
10 |
11 | gradle_node_version = 1.2.0
12 | gradle_android_version = 3.0.1
13 |
14 | coroutines_version = 0.23.3
15 |
16 | org.gradle.jvmargs=-Xmx1536m
17 |
--------------------------------------------------------------------------------
/gradle/publish.gradle:
--------------------------------------------------------------------------------
1 | def pomConfig = {
2 | licenses {
3 | license {
4 | name "The Apache Software License, Version 2.0"
5 | url "http://www.apache.org/licenses/LICENSE-2.0.txt"
6 | distribution "repo"
7 | }
8 | }
9 | developers {
10 | developer {
11 | id "JetBrains"
12 | name "JetBrains Team"
13 | organization "JetBrains"
14 | organizationUrl "http://www.jetbrains.com"
15 | }
16 | }
17 | scm {
18 | url "https://github.com/e5l/http-client-common"
19 | }
20 | }
21 |
22 | bintray {
23 | user = System.getenv('BINTRAY_USER')
24 | key = System.getenv('BINTRAY_API_KEY')
25 |
26 | pkg {
27 | userOrg = 'e5l'
28 | repo = 'http-client-common'
29 | name = "http-client-${project.name}"
30 | licenses = ['Apache-2.0']
31 | vcsUrl = 'https://github.com/e5l/http-client-common'
32 | }
33 | }
34 |
35 | publishing {
36 | if (project.name == 'ios') {
37 | repositories {
38 | maven {
39 | url = 'https://dl.bintray.com/e5l/http-client-common'
40 | }
41 | }
42 | }
43 | else {
44 | publications {
45 | mavenJava(MavenPublication) {
46 | from components.java
47 | }
48 | }
49 | }
50 | }
51 |
52 | afterEvaluate {
53 | project.publishing.publications.forEach { publication ->
54 | publication.pom.withXml {
55 | def root = asNode()
56 | root.appendNode('name', project.name)
57 | root.appendNode('description', 'Kotlin multiplatform http-client')
58 | root.appendNode('url', 'https://github.com/e5l/http-client-common')
59 | root.children().last() + pomConfig
60 | }
61 | }
62 | }
63 |
64 | bintrayUpload.doFirst {
65 | publications = project.publishing.publications
66 | }
67 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 19 20:22:43 MSK 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/ios/build.gradle:
--------------------------------------------------------------------------------
1 |
2 | sourceSets {
3 | main {
4 | component {
5 | target 'ios_arm64', 'ios_x64'
6 | outputKinds = [KLIBRARY]
7 | }
8 | }
9 | }
10 |
11 | dependencies {
12 | expectedBy project(':common')
13 | }
14 |
--------------------------------------------------------------------------------
/ios/src/main/kotlin/NativeHttpClient.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import platform.Foundation.*
4 | import kotlin.coroutines.experimental.*
5 |
6 | actual class HttpClient actual constructor() : Closeable {
7 |
8 | actual suspend fun request(request: HttpRequest): HttpResponse = suspendCoroutine { continuation ->
9 | val delegate = object : NSObject(), NSURLSessionDataDelegateProtocol {
10 | val receivedData = NSMutableData()
11 |
12 | override fun URLSession(session: NSURLSession, dataTask: NSURLSessionDataTask, didReceiveData: NSData) {
13 | receivedData.appendData(didReceiveData)
14 | }
15 |
16 | override fun URLSession(session: NSURLSession, task: NSURLSessionTask, didCompleteWithError: NSError?) {
17 | val rawResponse = task.response ?: return
18 | if (didCompleteWithError != null) return
19 |
20 | val responseData = rawResponse as NSHTTPURLResponse
21 |
22 | @Suppress("UNCHECKED_CAST")
23 | val headersDict = responseData.allHeaderFields as Map
24 |
25 | val response = HttpResponseBuilder(request).apply {
26 | statusCode = responseData.statusCode.toInt()
27 | headersDict.mapKeys { it ->
28 | headers[it.key] = listOf(it.value)
29 | }
30 |
31 | body = receivedData.decode(NSWindowsCP1251StringEncoding)
32 | }.build()
33 |
34 | continuation.resume(response)
35 | }
36 | }
37 |
38 | val session = NSURLSession.sessionWithConfiguration(
39 | NSURLSessionConfiguration.defaultSessionConfiguration(),
40 | delegate, delegateQueue = NSOperationQueue.mainQueue()
41 | )
42 |
43 | val URLString = request.url.build()
44 | val url = NSURL(string = URLString)
45 | val nativeRequest = NSMutableURLRequest.requestWithURL(url)
46 |
47 | request.headers.forEach { (key, values) ->
48 | values.forEach {
49 | nativeRequest.setValue(it, key)
50 | }
51 | }
52 |
53 | nativeRequest.setHTTPMethod(request.method.value)
54 | request.body?.let { nativeRequest.setHTTPBody(it.encode()) }
55 | session.dataTaskWithRequest(nativeRequest).resume()
56 | }
57 |
58 | override fun close() {
59 | }
60 | }
61 |
62 | private fun String.encode(): NSData = (this as NSString).dataUsingEncoding(NSWindowsCP1251StringEncoding)!!
63 |
64 | private fun NSData.decode(encoding: NSStringEncoding) = NSString.create(this, encoding)!! as String
65 |
--------------------------------------------------------------------------------
/ios/src/main/kotlin/NativeUtils.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlin.coroutines.experimental.*
4 |
5 | private class ContextlessContinuation(private val promise: Promise) : Continuation {
6 | override val context: CoroutineContext get() = EmptyCoroutineContext
7 |
8 | override fun resume(value: T) {
9 | promise.complete(value)
10 | }
11 |
12 | override fun resumeWithException(exception: Throwable) {
13 | promise.completeWithException(exception)
14 | }
15 | }
16 |
17 | actual fun promise(block: suspend () -> T): Promise {
18 | val result = Promise()
19 | block.startCoroutine(ContextlessContinuation(result))
20 | return result
21 | }
22 |
--------------------------------------------------------------------------------
/ios/src/main/kotlin/iphone.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | typealias NSObject = platform.darwin.NSObject
4 | typealias NSObjectMeta = platform.darwin.NSObjectMeta
5 |
--------------------------------------------------------------------------------
/jvm/build.gradle:
--------------------------------------------------------------------------------
1 | repositories {
2 | maven { url 'https://dl.bintray.com/kotlin/ktor' }
3 | maven { url 'https://dl.bintray.com/kotlin/kotlinx' }
4 | }
5 |
6 | dependencies {
7 | expectedBy project(':common')
8 |
9 | compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
10 | compile "io.ktor:ktor-client-cio:$ktor_version"
11 |
12 | testCompile 'junit:junit:4.12'
13 | testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
14 | testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
15 | }
16 |
17 | kotlin.experimental.coroutines 'enable'
18 |
19 | tasks.withType(compileKotlin.getClass()) {
20 | kotlinOptions {
21 | jvmTarget = '1.6'
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/jvm/src/main/kotlin/io/ktor/common/client/JvmHttpClient.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import io.ktor.client.engine.*
4 | import io.ktor.client.engine.cio.*
5 | import io.ktor.client.request.*
6 | import io.ktor.content.*
7 | import io.ktor.http.*
8 | import kotlinx.coroutines.experimental.io.*
9 | import kotlinx.coroutines.experimental.io.jvm.javaio.*
10 | import java.net.*
11 |
12 | actual class HttpClient actual constructor() : Closeable {
13 | private val client = io.ktor.client.HttpClient(CIO.config {
14 | https.randomAlgorithm = "SHA1PRNG"
15 | })
16 |
17 | actual suspend fun request(request: HttpRequest): HttpResponse {
18 | val contentType = request.headers[HttpHeaders.ContentType]?.let { ContentType.parse(it.first()) }
19 |
20 | val response = client.request {
21 | method = HttpMethod.parse(request.method.value)
22 | url.takeFrom(URL(request.url.build()))
23 | headers {
24 | request.headers.forEach { key, values -> appendAll(key, values) }
25 | }
26 |
27 | body = object : OutgoingContent.ReadChannelContent() {
28 | override val contentLength: Long? = request.body?.length?.toLong()
29 | override val contentType: ContentType? = contentType
30 |
31 | override fun readFrom(): ByteReadChannel =
32 | request.body?.let { ByteReadChannel(it.toByteArray()) }
33 | ?: EmptyByteReadChannel
34 |
35 | }
36 | }
37 |
38 | return HttpResponseBuilder(request).apply {
39 | statusCode = response.status.value
40 | response.headers.entries().forEach { (key, values) -> headers[key] = values }
41 | body = response.content
42 | .toInputStream()
43 | .reader(response.charset() ?: Charsets.UTF_8).readText()
44 | }.build()
45 | }
46 |
47 | override fun close() {
48 | client.close()
49 | }
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/jvm/src/main/kotlin/io/ktor/common/client/JvmUtils.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlinx.coroutines.experimental.*
4 |
5 | actual fun promise(block: suspend () -> T): Promise {
6 | val result = async {
7 | block()
8 | }
9 |
10 | return Promise().also {
11 | result.invokeOnCompletion { cause ->
12 | if (cause == null) {
13 | it.complete(result.getCompleted())
14 | } else {
15 | it.completeWithException(cause)
16 | }
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/jvm/src/test/kotlin/io/ktor/common/client/JvmTests.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import kotlinx.coroutines.experimental.*
4 | import kotlin.test.*
5 |
6 | class JvmTests {
7 |
8 | @Test
9 | fun testGet() = runBlocking {
10 | RequestTests.testGet()
11 | }
12 |
13 | }
--------------------------------------------------------------------------------
/samples/android-test-application/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/libraries
5 | /.idea/modules.xml
6 | /.idea/workspace.xml
7 | .DS_Store
8 | /build
9 | /captures
10 | .externalNativeBuild
11 |
--------------------------------------------------------------------------------
/samples/android-test-application/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/samples/android-test-application/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/samples/android-test-application/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/android-test-application/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/samples/android-test-application/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply plugin: 'kotlin-android'
4 | apply plugin: 'kotlin-android-extensions'
5 |
6 | android {
7 | compileSdkVersion 27
8 | defaultConfig {
9 | applicationId "com.example.jetbrains.android_test_application"
10 | minSdkVersion 24
11 | targetSdkVersion 27
12 | versionCode 1
13 | versionName "1.0"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 | buildTypes {
17 | release {
18 | minifyEnabled false
19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
20 | }
21 | }
22 | packagingOptions {
23 | exclude 'META-INF/main.kotlin_module'
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_1_8
27 | targetCompatibility JavaVersion.VERSION_1_8
28 | }
29 | }
30 |
31 | repositories {
32 | maven { url 'https://dl.bintray.com/kotlin/ktor' }
33 | maven { url 'https://dl.bintray.com/e5l/http-client-common' }
34 |
35 | }
36 |
37 | dependencies {
38 | implementation fileTree(include: ['*.jar'], dir: 'libs')
39 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
40 | implementation 'com.android.support:appcompat-v7:27.1.1'
41 | implementation 'com.android.support.constraint:constraint-layout:1.1.1'
42 | testImplementation 'junit:junit:4.12'
43 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
44 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
45 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:0.22.5'
46 | implementation "io.ktor.common.client:jvm:$http_client_version"
47 | implementation "io.ktor:ktor-client-cio:$ktor_version"
48 | }
49 | kotlin {
50 | experimental {
51 | coroutines "enable"
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/androidTest/java/com/example/jetbrains/android_test_application/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetbrains.android_test_application
2 |
3 | import android.support.test.InstrumentationRegistry
4 | import android.support.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getTargetContext()
22 | assertEquals("com.example.jetbrains.android_test_application", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/java/com/example/jetbrains/android_test_application/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetbrains.android_test_application
2 |
3 | import android.os.*
4 | import android.support.v7.app.*
5 | import android.text.*
6 | import android.text.method.*
7 | import android.widget.*
8 | import io.ktor.common.client.*
9 | import io.ktor.common.client.http.*
10 | import kotlinx.coroutines.experimental.*
11 | import kotlinx.coroutines.experimental.android.*
12 |
13 | class MainActivity : AppCompatActivity() {
14 | private val client = HttpClient()
15 |
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContentView(R.layout.activity_main)
19 |
20 | val view = findViewById(R.id.content).apply {
21 | movementMethod = ScrollingMovementMethod()
22 | }
23 |
24 | promise {
25 | client.request {
26 | url.apply {
27 | protocol = URLProtocol.HTTPS
28 | port = 443
29 | host = "kotlinlang.org"
30 | }
31 | }
32 | }.then {
33 | val content = Html.fromHtml(it.body, Html.FROM_HTML_MODE_COMPACT)
34 | launch(UI) { view.text = content }
35 | }.catch {
36 | Toast.makeText(this, it.cause.toString(), Toast.LENGTH_LONG).show()
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
23 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | android-test-application
3 |
4 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/android-test-application/app/src/test/java/com/example/jetbrains/android_test_application/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.example.jetbrains.android_test_application
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/samples/android-test-application/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.2.51'
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.2'
11 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
12 |
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/samples/android-test-application/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 |
15 | http_client_version=0.1.15
16 | ktor_version=0.9.3-alpha-5
17 |
--------------------------------------------------------------------------------
/samples/android-test-application/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/android-test-application/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/android-test-application/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Jun 06 09:58:42 MSK 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/samples/android-test-application/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/samples/android-test-application/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/samples/android-test-application/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/samples/ios-test-application/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/samples/ios-test-application/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/ios-test-application/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/ios-test-application/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | true
25 | DEFINITION_ORDER
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | 1528274840736
102 |
103 |
104 | 1528274840736
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/samples/ios-test-application/.idea/xcode.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/samples/ios-test-application/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url 'https://dl.bintray.com/jetbrains/kotlin-native-dependencies' }
4 | jcenter()
5 | }
6 |
7 | dependencies {
8 | classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:$kotlin_native_version"
9 | }
10 | }
11 |
12 | repositories {
13 | maven {
14 | url = 'https://dl.bintray.com/e5l/http-client-common'
15 | }
16 | }
17 |
18 | apply plugin: 'kotlin-platform-native'
19 |
20 | sourceSets {
21 | main {
22 | component {
23 | target 'ios_arm64', 'ios_x64'
24 | outputKinds = [EXECUTABLE]
25 | }
26 | }
27 | test {
28 | component {
29 | target 'ios_x64', 'ios_arm64'
30 | }
31 | }
32 | }
33 |
34 | dependencies {
35 | implementation "io.ktor.common.client:ios:$http_client_version"
36 | }
37 |
--------------------------------------------------------------------------------
/samples/ios-test-application/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin_native_version = 0.8
2 | http_client_version=0.1.15
3 |
--------------------------------------------------------------------------------
/samples/ios-test-application/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/ios-test-application/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/ios-test-application/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Mar 19 20:22:43 MSK 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-all.zip
7 |
--------------------------------------------------------------------------------
/samples/ios-test-application/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/samples/ios-test-application/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 48;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | B3C2FA5B2043FB2300787964 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B3C2FA5A2043FB2300787964 /* AppDelegate.m */; };
11 | B3C2FA5E2043FB2300787964 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B3C2FA5D2043FB2300787964 /* ViewController.m */; };
12 | B3C2FA612043FB2300787964 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B3C2FA5F2043FB2300787964 /* Main.storyboard */; };
13 | B3C2FA632043FB2300787964 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B3C2FA622043FB2300787964 /* Assets.xcassets */; };
14 | B3C2FA662043FB2300787964 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B3C2FA642043FB2300787964 /* LaunchScreen.storyboard */; };
15 | B3C2FA692043FB2300787964 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = B3C2FA682043FB2300787964 /* main.m */; };
16 | /* End PBXBuildFile section */
17 |
18 | /* Begin PBXFileReference section */
19 | B3C2FA562043FB2300787964 /* ios-test-application.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ios-test-application.app"; sourceTree = BUILT_PRODUCTS_DIR; };
20 | B3C2FA592043FB2300787964 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
21 | B3C2FA5A2043FB2300787964 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
22 | B3C2FA5C2043FB2300787964 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
23 | B3C2FA5D2043FB2300787964 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
24 | B3C2FA602043FB2300787964 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
25 | B3C2FA622043FB2300787964 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
26 | B3C2FA652043FB2300787964 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
27 | B3C2FA672043FB2300787964 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
28 | B3C2FA682043FB2300787964 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
29 | /* End PBXFileReference section */
30 |
31 | /* Begin PBXFrameworksBuildPhase section */
32 | B3C2FA532043FB2300787964 /* Frameworks */ = {
33 | isa = PBXFrameworksBuildPhase;
34 | buildActionMask = 2147483647;
35 | files = (
36 | );
37 | runOnlyForDeploymentPostprocessing = 0;
38 | };
39 | /* End PBXFrameworksBuildPhase section */
40 |
41 | /* Begin PBXGroup section */
42 | B3C2FA4D2043FB2300787964 = {
43 | isa = PBXGroup;
44 | children = (
45 | B3C2FA582043FB2300787964 /* ios-test-application */,
46 | B3C2FA572043FB2300787964 /* Products */,
47 | );
48 | sourceTree = "";
49 | };
50 | B3C2FA572043FB2300787964 /* Products */ = {
51 | isa = PBXGroup;
52 | children = (
53 | B3C2FA562043FB2300787964 /* ios-test-application.app */,
54 | );
55 | name = Products;
56 | sourceTree = "";
57 | };
58 | B3C2FA582043FB2300787964 /* ios-test-application */ = {
59 | isa = PBXGroup;
60 | children = (
61 | B3C2FA592043FB2300787964 /* AppDelegate.h */,
62 | B3C2FA5A2043FB2300787964 /* AppDelegate.m */,
63 | B3C2FA5C2043FB2300787964 /* ViewController.h */,
64 | B3C2FA5D2043FB2300787964 /* ViewController.m */,
65 | B3C2FA5F2043FB2300787964 /* Main.storyboard */,
66 | B3C2FA622043FB2300787964 /* Assets.xcassets */,
67 | B3C2FA642043FB2300787964 /* LaunchScreen.storyboard */,
68 | B3C2FA672043FB2300787964 /* Info.plist */,
69 | B3C2FA682043FB2300787964 /* main.m */,
70 | );
71 | path = "ios-test-application";
72 | sourceTree = "";
73 | };
74 | /* End PBXGroup section */
75 |
76 | /* Begin PBXNativeTarget section */
77 | B3C2FA552043FB2300787964 /* ios-test-application */ = {
78 | isa = PBXNativeTarget;
79 | buildConfigurationList = B3C2FA6C2043FB2300787964 /* Build configuration list for PBXNativeTarget "ios-test-application" */;
80 | buildPhases = (
81 | B3C2FA6F20440D2200787964 /* Remove Original Binary */,
82 | B3C2FA522043FB2300787964 /* Sources */,
83 | B3C2FA532043FB2300787964 /* Frameworks */,
84 | B3C2FA7020440D5E00787964 /* Build Binary From Kotlin Sources */,
85 | B3C2FA7120440D9900787964 /* Replace Binary */,
86 | B3C2FA542043FB2300787964 /* Resources */,
87 | );
88 | buildRules = (
89 | );
90 | dependencies = (
91 | );
92 | name = "ios-test-application";
93 | productName = "ios-test-application";
94 | productReference = B3C2FA562043FB2300787964 /* ios-test-application.app */;
95 | productType = "com.apple.product-type.application";
96 | };
97 | /* End PBXNativeTarget section */
98 |
99 | /* Begin PBXProject section */
100 | B3C2FA4E2043FB2300787964 /* Project object */ = {
101 | isa = PBXProject;
102 | attributes = {
103 | LastUpgradeCheck = 0920;
104 | ORGANIZATIONNAME = jetbrains;
105 | TargetAttributes = {
106 | B3C2FA552043FB2300787964 = {
107 | CreatedOnToolsVersion = 9.2;
108 | ProvisioningStyle = Automatic;
109 | };
110 | };
111 | };
112 | buildConfigurationList = B3C2FA512043FB2300787964 /* Build configuration list for PBXProject "ios-test-application" */;
113 | compatibilityVersion = "Xcode 8.0";
114 | developmentRegion = en;
115 | hasScannedForEncodings = 0;
116 | knownRegions = (
117 | en,
118 | Base,
119 | );
120 | mainGroup = B3C2FA4D2043FB2300787964;
121 | productRefGroup = B3C2FA572043FB2300787964 /* Products */;
122 | projectDirPath = "";
123 | projectRoot = "";
124 | targets = (
125 | B3C2FA552043FB2300787964 /* ios-test-application */,
126 | );
127 | };
128 | /* End PBXProject section */
129 |
130 | /* Begin PBXResourcesBuildPhase section */
131 | B3C2FA542043FB2300787964 /* Resources */ = {
132 | isa = PBXResourcesBuildPhase;
133 | buildActionMask = 2147483647;
134 | files = (
135 | B3C2FA662043FB2300787964 /* LaunchScreen.storyboard in Resources */,
136 | B3C2FA632043FB2300787964 /* Assets.xcassets in Resources */,
137 | B3C2FA612043FB2300787964 /* Main.storyboard in Resources */,
138 | );
139 | runOnlyForDeploymentPostprocessing = 0;
140 | };
141 | /* End PBXResourcesBuildPhase section */
142 |
143 | /* Begin PBXShellScriptBuildPhase section */
144 | B3C2FA6F20440D2200787964 /* Remove Original Binary */ = {
145 | isa = PBXShellScriptBuildPhase;
146 | buildActionMask = 2147483647;
147 | files = (
148 | );
149 | inputPaths = (
150 | );
151 | name = "Remove Original Binary";
152 | outputPaths = (
153 | );
154 | runOnlyForDeploymentPostprocessing = 0;
155 | shellPath = /bin/sh;
156 | shellScript = "rm -f \"$TARGET_BUILD_DIR/$EXECUTABLE_PATH\"";
157 | };
158 | B3C2FA7020440D5E00787964 /* Build Binary From Kotlin Sources */ = {
159 | isa = PBXShellScriptBuildPhase;
160 | buildActionMask = 2147483647;
161 | files = (
162 | );
163 | inputPaths = (
164 | );
165 | name = "Build Binary From Kotlin Sources";
166 | outputPaths = (
167 | );
168 | runOnlyForDeploymentPostprocessing = 0;
169 | shellPath = /bin/sh;
170 | shellScript = "case \"$PLATFORM_NAME\" in\niphoneos)\nTARGET=ios_arm64\nTASK=compileDebugIos_arm64KotlinNative\n;;\niphonesimulator)\nTARGET=ios_x64\nTASK=compileDebugIos_x64KotlinNative\n\n;;\n*)\necho \"Unknown platform: $PLATFORN_NAME\"\nexit 1\n;;\nesac\n\n# ./build/exe/main/debug/ios_arm64/ios-test-application.kexe\nmkdir -p \"$SRCROOT/build/konan/bin/\"\nrm -f \"$SRCROOT/build/konan/bin/xcode\"\nln -s \"$SRCROOT/build/exe/main/debug/$TARGET\" \"$SRCROOT/build/konan/bin/xcode\"\n\n\"$SRCROOT/gradlew\" -p \"$SRCROOT\" \"$TASK\"";
171 | };
172 | B3C2FA7120440D9900787964 /* Replace Binary */ = {
173 | isa = PBXShellScriptBuildPhase;
174 | buildActionMask = 2147483647;
175 | files = (
176 | );
177 | inputPaths = (
178 | );
179 | name = "Replace Binary";
180 | outputPaths = (
181 | );
182 | runOnlyForDeploymentPostprocessing = 0;
183 | shellPath = /bin/sh;
184 | shellScript = "echo \"$SRCROOT\"\ncp \"$SRCROOT/build/konan/bin/xcode/ios-test-application.kexe\" \"$TARGET_BUILD_DIR/$EXECUTABLE_PATH\"";
185 | };
186 | /* End PBXShellScriptBuildPhase section */
187 |
188 | /* Begin PBXSourcesBuildPhase section */
189 | B3C2FA522043FB2300787964 /* Sources */ = {
190 | isa = PBXSourcesBuildPhase;
191 | buildActionMask = 2147483647;
192 | files = (
193 | B3C2FA5E2043FB2300787964 /* ViewController.m in Sources */,
194 | B3C2FA692043FB2300787964 /* main.m in Sources */,
195 | B3C2FA5B2043FB2300787964 /* AppDelegate.m in Sources */,
196 | );
197 | runOnlyForDeploymentPostprocessing = 0;
198 | };
199 | /* End PBXSourcesBuildPhase section */
200 |
201 | /* Begin PBXVariantGroup section */
202 | B3C2FA5F2043FB2300787964 /* Main.storyboard */ = {
203 | isa = PBXVariantGroup;
204 | children = (
205 | B3C2FA602043FB2300787964 /* Base */,
206 | );
207 | name = Main.storyboard;
208 | sourceTree = "";
209 | };
210 | B3C2FA642043FB2300787964 /* LaunchScreen.storyboard */ = {
211 | isa = PBXVariantGroup;
212 | children = (
213 | B3C2FA652043FB2300787964 /* Base */,
214 | );
215 | name = LaunchScreen.storyboard;
216 | sourceTree = "";
217 | };
218 | /* End PBXVariantGroup section */
219 |
220 | /* Begin XCBuildConfiguration section */
221 | B3C2FA6A2043FB2300787964 /* Debug */ = {
222 | isa = XCBuildConfiguration;
223 | buildSettings = {
224 | ALWAYS_SEARCH_USER_PATHS = NO;
225 | CLANG_ANALYZER_NONNULL = YES;
226 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
227 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
228 | CLANG_CXX_LIBRARY = "libc++";
229 | CLANG_ENABLE_MODULES = YES;
230 | CLANG_ENABLE_OBJC_ARC = YES;
231 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
232 | CLANG_WARN_BOOL_CONVERSION = YES;
233 | CLANG_WARN_COMMA = YES;
234 | CLANG_WARN_CONSTANT_CONVERSION = YES;
235 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
236 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
237 | CLANG_WARN_EMPTY_BODY = YES;
238 | CLANG_WARN_ENUM_CONVERSION = YES;
239 | CLANG_WARN_INFINITE_RECURSION = YES;
240 | CLANG_WARN_INT_CONVERSION = YES;
241 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
242 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
244 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
245 | CLANG_WARN_STRICT_PROTOTYPES = YES;
246 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
247 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
248 | CLANG_WARN_UNREACHABLE_CODE = YES;
249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
250 | CODE_SIGN_IDENTITY = "iPhone Developer";
251 | COPY_PHASE_STRIP = NO;
252 | DEBUG_INFORMATION_FORMAT = dwarf;
253 | ENABLE_STRICT_OBJC_MSGSEND = YES;
254 | ENABLE_TESTABILITY = YES;
255 | GCC_C_LANGUAGE_STANDARD = gnu11;
256 | GCC_DYNAMIC_NO_PIC = NO;
257 | GCC_NO_COMMON_BLOCKS = YES;
258 | GCC_OPTIMIZATION_LEVEL = 0;
259 | GCC_PREPROCESSOR_DEFINITIONS = (
260 | "DEBUG=1",
261 | "$(inherited)",
262 | );
263 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
264 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
265 | GCC_WARN_UNDECLARED_SELECTOR = YES;
266 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
267 | GCC_WARN_UNUSED_FUNCTION = YES;
268 | GCC_WARN_UNUSED_VARIABLE = YES;
269 | IPHONEOS_DEPLOYMENT_TARGET = 11.2;
270 | MTL_ENABLE_DEBUG_INFO = YES;
271 | ONLY_ACTIVE_ARCH = YES;
272 | SDKROOT = iphoneos;
273 | };
274 | name = Debug;
275 | };
276 | B3C2FA6B2043FB2300787964 /* Release */ = {
277 | isa = XCBuildConfiguration;
278 | buildSettings = {
279 | ALWAYS_SEARCH_USER_PATHS = NO;
280 | CLANG_ANALYZER_NONNULL = YES;
281 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
282 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
283 | CLANG_CXX_LIBRARY = "libc++";
284 | CLANG_ENABLE_MODULES = YES;
285 | CLANG_ENABLE_OBJC_ARC = YES;
286 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
287 | CLANG_WARN_BOOL_CONVERSION = YES;
288 | CLANG_WARN_COMMA = YES;
289 | CLANG_WARN_CONSTANT_CONVERSION = YES;
290 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
291 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
292 | CLANG_WARN_EMPTY_BODY = YES;
293 | CLANG_WARN_ENUM_CONVERSION = YES;
294 | CLANG_WARN_INFINITE_RECURSION = YES;
295 | CLANG_WARN_INT_CONVERSION = YES;
296 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
297 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
298 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
299 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
300 | CLANG_WARN_STRICT_PROTOTYPES = YES;
301 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
302 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
303 | CLANG_WARN_UNREACHABLE_CODE = YES;
304 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
305 | CODE_SIGN_IDENTITY = "iPhone Developer";
306 | COPY_PHASE_STRIP = NO;
307 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
308 | ENABLE_NS_ASSERTIONS = NO;
309 | ENABLE_STRICT_OBJC_MSGSEND = YES;
310 | GCC_C_LANGUAGE_STANDARD = gnu11;
311 | GCC_NO_COMMON_BLOCKS = YES;
312 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
313 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
314 | GCC_WARN_UNDECLARED_SELECTOR = YES;
315 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
316 | GCC_WARN_UNUSED_FUNCTION = YES;
317 | GCC_WARN_UNUSED_VARIABLE = YES;
318 | IPHONEOS_DEPLOYMENT_TARGET = 11.2;
319 | MTL_ENABLE_DEBUG_INFO = NO;
320 | SDKROOT = iphoneos;
321 | VALIDATE_PRODUCT = YES;
322 | };
323 | name = Release;
324 | };
325 | B3C2FA6D2043FB2300787964 /* Debug */ = {
326 | isa = XCBuildConfiguration;
327 | buildSettings = {
328 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
329 | CODE_SIGN_STYLE = Automatic;
330 | INFOPLIST_FILE = "ios-test-application/Info.plist";
331 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
332 | PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.ios-test-application";
333 | PRODUCT_NAME = "$(TARGET_NAME)";
334 | TARGETED_DEVICE_FAMILY = "1,2";
335 | };
336 | name = Debug;
337 | };
338 | B3C2FA6E2043FB2300787964 /* Release */ = {
339 | isa = XCBuildConfiguration;
340 | buildSettings = {
341 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
342 | CODE_SIGN_STYLE = Automatic;
343 | INFOPLIST_FILE = "ios-test-application/Info.plist";
344 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
345 | PRODUCT_BUNDLE_IDENTIFIER = "org.jetbrains.ios-test-application";
346 | PRODUCT_NAME = "$(TARGET_NAME)";
347 | TARGETED_DEVICE_FAMILY = "1,2";
348 | };
349 | name = Release;
350 | };
351 | /* End XCBuildConfiguration section */
352 |
353 | /* Begin XCConfigurationList section */
354 | B3C2FA512043FB2300787964 /* Build configuration list for PBXProject "ios-test-application" */ = {
355 | isa = XCConfigurationList;
356 | buildConfigurations = (
357 | B3C2FA6A2043FB2300787964 /* Debug */,
358 | B3C2FA6B2043FB2300787964 /* Release */,
359 | );
360 | defaultConfigurationIsVisible = 0;
361 | defaultConfigurationName = Release;
362 | };
363 | B3C2FA6C2043FB2300787964 /* Build configuration list for PBXNativeTarget "ios-test-application" */ = {
364 | isa = XCConfigurationList;
365 | buildConfigurations = (
366 | B3C2FA6D2043FB2300787964 /* Debug */,
367 | B3C2FA6E2043FB2300787964 /* Release */,
368 | );
369 | defaultConfigurationIsVisible = 0;
370 | defaultConfigurationName = Release;
371 | };
372 | /* End XCConfigurationList section */
373 | };
374 | rootObject = B3C2FA4E2043FB2300787964 /* Project object */;
375 | }
376 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcuserdata/jetbrains.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcuserdata/leonid.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/ios-test-application/ios-test-application.xcodeproj/project.xcworkspace/xcuserdata/leonid.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/xcuserdata/jetbrains.xcuserdatad/xcschemes/ios-test-application.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
8 |
14 |
15 |
16 |
17 |
18 |
22 |
23 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/xcuserdata/jetbrains.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ios-test-application.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/xcuserdata/leonid.xcuserdatad/xcschemes/ios-test-application.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
31 |
32 |
33 |
34 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
58 |
64 |
65 |
66 |
67 |
68 |
69 |
75 |
77 |
83 |
84 |
85 |
86 |
88 |
89 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application.xcodeproj/xcuserdata/leonid.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | ios-test-application.xcscheme
8 |
9 | orderHint
10 | 0
11 |
12 |
13 | SuppressBuildableAutocreation
14 |
15 | B3C2FA552043FB2300787964
16 |
17 | primary
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface AppDelegate : UIResponder
4 |
5 | @property (strong, nonatomic) UIWindow *window;
6 |
7 |
8 | @end
9 |
10 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 |
3 | @interface AppDelegate ()
4 |
5 | @end
6 |
7 | @implementation AppDelegate
8 |
9 |
10 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
11 | // Override point for customization after application launch.
12 | return YES;
13 | }
14 |
15 |
16 | - (void)applicationWillResignActive:(UIApplication *)application {
17 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
18 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
19 | }
20 |
21 |
22 | - (void)applicationDidEnterBackground:(UIApplication *)application {
23 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
24 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
25 | }
26 |
27 |
28 | - (void)applicationWillEnterForeground:(UIApplication *)application {
29 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
30 | }
31 |
32 |
33 | - (void)applicationDidBecomeActive:(UIApplication *)application {
34 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
35 | }
36 |
37 |
38 | - (void)applicationWillTerminate:(UIApplication *)application {
39 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
40 | }
41 |
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | },
43 | {
44 | "idiom" : "ipad",
45 | "size" : "20x20",
46 | "scale" : "1x"
47 | },
48 | {
49 | "idiom" : "ipad",
50 | "size" : "20x20",
51 | "scale" : "2x"
52 | },
53 | {
54 | "idiom" : "ipad",
55 | "size" : "29x29",
56 | "scale" : "1x"
57 | },
58 | {
59 | "idiom" : "ipad",
60 | "size" : "29x29",
61 | "scale" : "2x"
62 | },
63 | {
64 | "idiom" : "ipad",
65 | "size" : "40x40",
66 | "scale" : "1x"
67 | },
68 | {
69 | "idiom" : "ipad",
70 | "size" : "40x40",
71 | "scale" : "2x"
72 | },
73 | {
74 | "idiom" : "ipad",
75 | "size" : "76x76",
76 | "scale" : "1x"
77 | },
78 | {
79 | "idiom" : "ipad",
80 | "size" : "76x76",
81 | "scale" : "2x"
82 | },
83 | {
84 | "idiom" : "ipad",
85 | "size" : "83.5x83.5",
86 | "scale" : "2x"
87 | },
88 | {
89 | "idiom" : "ios-marketing",
90 | "size" : "1024x1024",
91 | "scale" : "1x"
92 | }
93 | ],
94 | "info" : {
95 | "version" : 1,
96 | "author" : "xcode"
97 | }
98 | }
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | NSAppTransportSecurity
6 |
7 | NSAllowsArbitraryLoads
8 |
9 |
10 | CFBundleDevelopmentRegion
11 | $(DEVELOPMENT_LANGUAGE)
12 | CFBundleExecutable
13 | $(EXECUTABLE_NAME)
14 | CFBundleIdentifier
15 | $(PRODUCT_BUNDLE_IDENTIFIER)
16 | CFBundleInfoDictionaryVersion
17 | 6.0
18 | CFBundleName
19 | $(PRODUCT_NAME)
20 | CFBundlePackageType
21 | APPL
22 | CFBundleShortVersionString
23 | 1.0
24 | CFBundleVersion
25 | 1
26 | LSRequiresIPhoneOS
27 |
28 | UILaunchStoryboardName
29 | LaunchScreen
30 | UIMainStoryboardFile
31 | Main
32 | UIRequiredDeviceCapabilities
33 |
34 | armv7
35 |
36 | UISupportedInterfaceOrientations
37 |
38 | UIInterfaceOrientationPortrait
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UISupportedInterfaceOrientations~ipad
43 |
44 | UIInterfaceOrientationPortrait
45 | UIInterfaceOrientationPortraitUpsideDown
46 | UIInterfaceOrientationLandscapeLeft
47 | UIInterfaceOrientationLandscapeRight
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/ViewController.h:
--------------------------------------------------------------------------------
1 | #import
2 |
3 | @interface ViewController : UIViewController
4 |
5 | @property (weak, nonatomic) IBOutlet UILabel *label;
6 | @property (weak, nonatomic) IBOutlet UITextField *textField;
7 | @property (weak, nonatomic) IBOutlet UIButton *button;
8 |
9 | - (IBAction)buttonPressed;
10 |
11 | @end
12 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/ViewController.m:
--------------------------------------------------------------------------------
1 | #import "ViewController.h"
2 |
3 | @interface ViewController ()
4 |
5 | @end
6 |
7 | @implementation ViewController
8 |
9 | - (void)viewDidLoad {
10 | [super viewDidLoad];
11 | // Do any additional setup after loading the view, typically from a nib.
12 | }
13 |
14 |
15 | - (void)didReceiveMemoryWarning {
16 | [super didReceiveMemoryWarning];
17 | // Dispose of any resources that can be recreated.
18 | }
19 |
20 | - (IBAction)buttonPressed {
21 | }
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/samples/ios-test-application/ios-test-application/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import "AppDelegate.h"
3 |
4 | int main(int argc, char * argv[]) {
5 | @autoreleasepool {
6 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/ios-test-application/settings.gradle:
--------------------------------------------------------------------------------
1 | enableFeaturePreview('GRADLE_METADATA')
2 |
--------------------------------------------------------------------------------
/samples/ios-test-application/src/main/kotlin/main.kt:
--------------------------------------------------------------------------------
1 | import kotlinx.cinterop.*
2 | import platform.Foundation.*
3 | import platform.UIKit.*
4 | import io.ktor.common.client.*
5 | import io.ktor.common.client.http.*
6 |
7 | fun main(args: Array) {
8 | memScoped {
9 | val argc = args.size + 1
10 | val argv = (arrayOf("konan") + args).map { it.cstr.ptr }.toCValues()
11 |
12 | autoreleasepool {
13 | UIApplicationMain(argc, argv, null, NSStringFromClass(AppDelegate))
14 | }
15 | }
16 | }
17 |
18 | class AppDelegate @OverrideInit constructor() : UIResponder(), UIApplicationDelegateProtocol {
19 | companion object : UIResponderMeta(), UIApplicationDelegateProtocolMeta {}
20 |
21 | private var _window: UIWindow? = null
22 | override fun window() = _window
23 | override fun setWindow(window: UIWindow?) {
24 | _window = window
25 | }
26 | }
27 |
28 |
29 | @ExportObjCClass
30 | class ViewController : UIViewController {
31 |
32 | @OverrideInit
33 | constructor(coder: NSCoder) : super(coder)
34 |
35 | @ObjCOutlet
36 | lateinit var label: UILabel
37 |
38 | @ObjCOutlet
39 | lateinit var textField: UITextField
40 |
41 | @ObjCOutlet
42 | lateinit var button: UIButton
43 |
44 | @ObjCAction
45 | fun buttonPressed() {
46 | performRequest(textField.text!!)
47 | }
48 |
49 | fun performRequest(endpoint: String) {
50 | val HEADER = "---==="
51 | val client = HttpClient()
52 |
53 | promise {
54 | client.request {
55 | with(url) {
56 | protocol = URLProtocol.HTTPS
57 | host = endpoint
58 | port = 443
59 | }
60 | }
61 | }.then { response ->
62 | println("$HEADER request: ${response.request.url}")
63 | println("$HEADER response status: ${response.statusCode}")
64 | println("$HEADER headers:")
65 | response.headers.forEach { (key, values) ->
66 | println(" -$key: ${values.joinToString()}")
67 | }
68 | println("$HEADER body:")
69 | println(response.body)
70 | label.text = response.body
71 |
72 | client.close()
73 | }
74 | }
75 | }
76 |
77 |
78 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/usage.statistics.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/web-test-application/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/samples/web-test-application/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | maven { url 'https://dl.bintray.com/kotlin/kotlin-dev' }
4 | maven { url 'https://plugins.gradle.org/m2/' }
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
9 | classpath "com.moowork.gradle:gradle-node-plugin:$gradle_node_version"
10 | }
11 | }
12 | apply plugin: "kotlin2js"
13 | apply plugin: "kotlin-dce-js"
14 | apply plugin: "com.moowork.node"
15 |
16 | repositories {
17 | maven { url "http://dl.bintray.com/kotlin/kotlin-dev" }
18 | maven { url "http://dl.bintray.com/kotlinx/kotlinx" }
19 | maven { url "http://dl.bintray.com/hypnosphi/kotlin-wrappers" }
20 | maven { url "https://dl.bintray.com/e5l/http-client-common" }
21 | mavenCentral()
22 | }
23 |
24 | dependencies {
25 | compile "org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version"
26 | compile "io.ktor.common.client:browser:$http_client_version"
27 | }
28 |
29 | compileKotlin2Js {
30 | kotlinOptions {
31 | sourceMap = true
32 | sourceMapEmbedSources = 'always'
33 | moduleKind = 'umd'
34 | metaInfo = false
35 | }
36 | }
37 |
38 | kotlin.experimental.coroutines 'enable'
39 |
40 | task copyStatic(type: Copy) {
41 | from "$rootDir/src/main/web"
42 | into "$buildDir/web"
43 | }
44 |
45 | task buildBundle(type: NpmTask, dependsOn: [npmInstall, runDceKotlinJs]) {
46 | args = ["run", "dist"]
47 | }
48 |
49 | task copyKotlinJs(type: Copy, dependsOn: compileKotlin2Js) {
50 | def workDir = "$buildDir/classes/kotlin/main/"
51 | from(workDir) {
52 | include "*.js"
53 | include "*.js.map"
54 | }
55 | into "$workDir/dependencies"
56 | }
57 |
58 | task devBuild(dependsOn: [npmInstall, copyStatic, copyKotlinJs])
59 |
60 | assemble.dependsOn buildBundle, copyStatic
61 |
--------------------------------------------------------------------------------
/samples/web-test-application/gradle.properties:
--------------------------------------------------------------------------------
1 | kotlin_version=1.2.51
2 | gradle_node_version=0.6
3 | http_client_version=0.1.15
4 |
--------------------------------------------------------------------------------
/samples/web-test-application/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/e5l/http-client-common/998ee1efc53252240c42aae54963b95d0379393e/samples/web-test-application/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/samples/web-test-application/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/samples/web-test-application/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/samples/web-test-application/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/samples/web-test-application/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "node-watch": "^0.5.7",
4 | "source-map-loader": "^0.2.3",
5 | "webpack": "^4.1.0",
6 | "webpack-cli": "^2.0.10",
7 | "webpack-merge": "^4.1.2"
8 | },
9 | "devDependencies": {
10 | "npm-run-all": "^4.1.2",
11 | "uglifyjs-webpack-plugin": "^1.2.2",
12 | "webpack-dev-server": "^3.1.0"
13 | },
14 | "scripts": {
15 | "devServer": "webpack-dev-server --open --config webpack.dev.js",
16 | "gradleBuild": "../gradlew devBuild --continuous",
17 | "serve": "run-p gradleBuild devServer",
18 | "dist": "webpack"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/samples/web-test-application/src/main/js/index.js:
--------------------------------------------------------------------------------
1 | require("browser.js");
2 | require("web-test-application.js");
3 |
--------------------------------------------------------------------------------
/samples/web-test-application/src/main/kotlin/io/ktor/common/client/test.kt:
--------------------------------------------------------------------------------
1 | package io.ktor.common.client
2 |
3 | import io.ktor.common.client.http.*
4 | import kotlinx.coroutines.experimental.*
5 |
6 | fun main(args: Array) {
7 | val client = HttpClient()
8 | promise {
9 | client.request {
10 | url.apply {
11 | protocol = URLProtocol.HTTPS
12 | host = "cors-anywhere.herokuapp.com"
13 | encodedPath = "/google.ru"
14 | port = 443
15 | }
16 | }
17 | }.then {
18 | println(it.body)
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/samples/web-test-application/src/main/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/samples/web-test-application/webpack.common.js:
--------------------------------------------------------------------------------
1 | var path = require("path");
2 |
3 | module.exports = {
4 | entry: path.resolve(__dirname, "src/main/js/index.js"),
5 | output: {
6 | path: path.resolve(__dirname, "build/web"),
7 | filename: "bundle.js"
8 | },
9 | resolve: {
10 | modules: [
11 | path.resolve(__dirname, "node_modules"),
12 | path.resolve(__dirname, "build/kotlin-js-min/main/")
13 | ]
14 | },
15 | module: {
16 | rules: [
17 | {
18 | test: /\.js$/,
19 | use: ["source-map-loader"],
20 | enforce: "pre"
21 | }
22 | ]
23 | }
24 | };
25 |
--------------------------------------------------------------------------------
/samples/web-test-application/webpack.config.js:
--------------------------------------------------------------------------------
1 | var webpack = require("webpack");
2 | var merge = require("webpack-merge");
3 | var common = require("./webpack.common.js");
4 |
5 | module.exports = merge(common, {
6 | devtool: "source-map",
7 | plugins: [
8 | new webpack.DefinePlugin({
9 | 'process.env': {
10 | NODE_ENV: JSON.stringify('production')
11 | }
12 | })
13 | // new webpack.optimize.UglifyJsPlugin({
14 | // sourceMap: true
15 | // })
16 | ]
17 | });
18 |
--------------------------------------------------------------------------------
/samples/web-test-application/webpack.dev.js:
--------------------------------------------------------------------------------
1 | var webpack = require("webpack");
2 | var merge = require("webpack-merge");
3 | var path = require("path");
4 |
5 | var kotlinPath = path.resolve(__dirname, "build/kotlin-js-min/main");
6 | module.exports = merge(require("./webpack.common.js"), {
7 | devtool: "inline-source-map",
8 | resolve: {
9 | modules: [path.resolve(kotlinPath, "dependencies/")]
10 | },
11 | devServer: {
12 | contentBase: "./src/main/web/",
13 | port: 9000,
14 | hot: true,
15 | headers: {
16 | "Access-Control-Allow-Origin": "*"
17 | }
18 | },
19 | plugins: [
20 | new webpack.HotModuleReplacementPlugin()
21 | ]
22 | });
23 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'http-client-common'
2 | enableFeaturePreview('GRADLE_METADATA')
3 |
4 | include 'common'
5 | include 'jvm'
6 | include 'ios'
7 | include 'browser'
8 |
--------------------------------------------------------------------------------