@react-native-hero/network 0.0.9 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/android/build.gradle
CHANGED
|
@@ -3,8 +3,8 @@ buildscript {
|
|
|
3
3
|
def kotlinVersion = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : '1.3.40'
|
|
4
4
|
|
|
5
5
|
repositories {
|
|
6
|
-
jcenter()
|
|
7
6
|
google()
|
|
7
|
+
mavenCentral()
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
@@ -38,4 +38,4 @@ dependencies {
|
|
|
38
38
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${safeExtGet('kotlinVersion', '1.3.40')}"
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
apply plugin: 'kotlin-android'
|
|
41
|
+
apply plugin: 'kotlin-android'
|
|
@@ -184,11 +184,11 @@ class RNTNetworkModule(private val reactContext: ReactApplicationContext) : Reac
|
|
|
184
184
|
val map = Arguments.createMap()
|
|
185
185
|
map.putInt("status_code", response.code)
|
|
186
186
|
|
|
187
|
-
val
|
|
187
|
+
val headerMap = Arguments.createMap()
|
|
188
188
|
for ((key, value) in response.headers) {
|
|
189
|
-
|
|
189
|
+
headerMap.putString(key, value)
|
|
190
190
|
}
|
|
191
|
-
map.putMap("headers",
|
|
191
|
+
map.putMap("headers", headerMap)
|
|
192
192
|
map.putString("body", response.body?.string())
|
|
193
193
|
|
|
194
194
|
promise.resolve(map)
|
|
@@ -218,13 +218,13 @@ class RNTNetworkModule(private val reactContext: ReactApplicationContext) : Reac
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
val client = OkHttpClient()
|
|
221
|
-
val isPost = method.
|
|
221
|
+
val isPost = method.uppercase(Locale.ROOT) == "POST"
|
|
222
222
|
|
|
223
223
|
var requestBody: RequestBody? = null
|
|
224
224
|
|
|
225
225
|
if (isPost) {
|
|
226
226
|
data?.let {
|
|
227
|
-
requestBody = JSONObject(it).toString().toRequestBody(JSON)
|
|
227
|
+
requestBody = JSONObject(it as Map<*, *>).toString().toRequestBody(JSON)
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
else {
|
|
@@ -259,11 +259,11 @@ class RNTNetworkModule(private val reactContext: ReactApplicationContext) : Reac
|
|
|
259
259
|
val map = Arguments.createMap()
|
|
260
260
|
map.putInt("status_code", response.code)
|
|
261
261
|
|
|
262
|
-
val
|
|
262
|
+
val headerMap = Arguments.createMap()
|
|
263
263
|
for ((key, value) in response.headers) {
|
|
264
|
-
|
|
264
|
+
headerMap.putString(key, value)
|
|
265
265
|
}
|
|
266
|
-
map.putMap("headers",
|
|
266
|
+
map.putMap("headers", headerMap)
|
|
267
267
|
map.putString("body", response.body?.string())
|
|
268
268
|
|
|
269
269
|
promise.resolve(map)
|