# Ktor: accept and accept-encoding issues

**URL:** <https://discuss.kotlinlang.org/t/ktor-accept-and-accept-encoding-issues/22475>\
**Category:** Libraries\
**Created:** [July 21, 2021, 6:57pm UTC](https://discuss.kotlinlang.org/t/ktor-accept-and-accept-encoding-issues/22475 "2021-07-21T18:57:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Psijic](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/psijic/32/2227_2.png) [@Psijic](https://discuss.kotlinlang.org/u/Psijic)\
**Post date:** [July 21, 2021, 6:57pm UTC](https://discuss.kotlinlang.org/t/ktor-accept-and-accept-encoding-issues/22475/1 "2021-07-21T18:57:53Z")

</div>

Hello, I have a sensitive server that can pass `curl` requests well but there are troubles with `Ktor` same requests. While I have completely same headers and data, I found 2 issues:  
`Ktor` adds `application/json` to `accept` even if it’s already used here  
(i.e. `accept: application/json,*/*,application/json`)  
If I add `accept-encoding: deflate, gzip, br, zstd`,  
there is an error: `io.ktor.utils.io.charsets.MalformedInputException: Input length = 1`.  
But all is ok with the `curl` request

Common headers:

```auto
POST / HTTP/1.1
Host: 127.0.0.1:8080
accept-encoding: deflate, gzip, br, zstd
Accept-Charset: UTF-8
Content-Length: 124
Content-Type: application/json; charset=UTF-8

```

Method:

```auto
    suspend fun postHttpAsync(url: String, headersMap: Map<String, String>, data: Any? = null) = coroutineScope {
        return@coroutineScope httpClient.post<HttpResponse>(url) {
            for (element in headersMap) headers[element.key] = element.value
            data?.let { body = it }
        }
    }

```

Request headers:

```auto
requestHeaders = hashMapOf(
            "content-type" to "application/json; charset=UTF-8",
            "Accept" to "*/*", // Bug: it becomes "*/*,application/json"
            "Accept-Charset" to "UTF-8",
            "accept-encoding" to "deflate, gzip, br, zstd"
)

```

---

<div class="post-metadata">

**Author:** ![franco](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/franco/32/7390_2.png) [@franco](https://discuss.kotlinlang.org/u/franco)\
**Post date:** [December 8, 2021, 6:28am UTC](https://discuss.kotlinlang.org/t/ktor-accept-and-accept-encoding-issues/22475/2 "2021-12-08T06:28:08Z")

</div>

Hi Psijic, did you find a workaround for the `MalformedInputException `?
