File tree Expand file tree Collapse file tree 2 files changed +64
-0
lines changed
library/src/main/java/com/nextcloud Expand file tree Collapse file tree 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Nextcloud Android Library
3
+ *
4
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
5
+ * SPDX-FileCopyrightText: 2024 ZetaTom <[email protected] >
6
+ * SPDX-License-Identifier: MIT
7
+ */
8
+ package com.nextcloud.common
9
+
10
+ import com.google.gson.Gson
11
+ import okhttp3.MediaType.Companion.toMediaType
12
+ import okhttp3.RequestBody
13
+ import okhttp3.RequestBody.Companion.toRequestBody
14
+
15
+ class JSONRequestBody () {
16
+ private val content = mutableMapOf<String , String >()
17
+
18
+ constructor (key: String , value: String ) : this () {
19
+ put(key, value)
20
+ }
21
+
22
+ fun put (
23
+ key : String ,
24
+ value : String
25
+ ) {
26
+ content[key] = value
27
+ }
28
+
29
+ fun get (): RequestBody {
30
+ val json = Gson ().toJson(content)
31
+ return json.toRequestBody(JSON_MEDIATYPE )
32
+ }
33
+
34
+ override fun toString (): String {
35
+ return content.toString()
36
+ }
37
+
38
+ companion object {
39
+ private val JSON_MEDIATYPE = " application/json; charset=utf-8" .toMediaType()
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Nextcloud Android Library
3
+ *
4
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
5
+ * SPDX-FileCopyrightText: 2024 ZetaTom <[email protected] >
6
+ * SPDX-License-Identifier: MIT
7
+ */
8
+ package com.nextcloud.operations
9
+
10
+ import com.nextcloud.common.OkHttpMethodBase
11
+ import okhttp3.Request
12
+
13
+ /* *
14
+ * HTTP HEAD method that uses OkHttp with new NextcloudClient
15
+ */
16
+ class HeadMethod (
17
+ uri : String ,
18
+ useOcsApiRequestHeader : Boolean
19
+ ) : OkHttpMethodBase(uri, useOcsApiRequestHeader) {
20
+ override fun applyType (temp : Request .Builder ) {
21
+ temp.head()
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments