mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
InternetUtils: Honor content-type header
This commit is contained in:
@@ -172,7 +172,8 @@ class InternetUtils {
|
|||||||
// Convert body string to RequestBody if allowed
|
// Convert body string to RequestBody if allowed
|
||||||
val requestBody: RequestBody? =
|
val requestBody: RequestBody? =
|
||||||
if (body != null && method.uppercase() !in listOf("GET", "HEAD")) {
|
if (body != null && method.uppercase() !in listOf("GET", "HEAD")) {
|
||||||
body.toRequestBody("application/octet-stream".toMediaType())
|
val contentType = getHeader(requestHeaders, "content-type") ?: "application/octet-stream"
|
||||||
|
body.toRequestBody(contentType.toMediaType())
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
// Configure HTTP method
|
// Configure HTTP method
|
||||||
@@ -226,6 +227,16 @@ class InternetUtils {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getHeader(headers: Map<String, String>, key: String): String? {
|
||||||
|
for (e in headers) {
|
||||||
|
if (e.key.equals(key, ignoreCase = true)) {
|
||||||
|
return e.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an OkHttpClient that accepts all SSL certificates (insecure).
|
* Creates an OkHttpClient that accepts all SSL certificates (insecure).
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user