AndroidClientEngine set a Content-Lenght: 2 on a GET request with an EmptyContent as body
See original GitHub issueKtor Version and Engine Used (client or server and name) 1.3.2
Describe the bug
- On a
GET
request, the body is anEmptyContent
- The
JsonFeature
with aKotlinxSerializer
serialize thisEmptyContent
as{}
Code Here - The
AndroidClientEngine
calculateContent-Length
based on this{}
and set it to2
Code Here - Then the
GET
request is executed without body but with aContent-Lenght: 2
header
Expected behavior
GET
request executed without body and with a Content-Lenght: 0
header
Maybe, this PR could resolve this issue ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
EmptyContent - ktor
Concrete OutgoingContent without a payload. Functions Properties Extensions. Functions. getProperty.
Read more >Web API - Handling HEAD requests and specify custom ...
Return a Body with at least one byte content, set the Content-Length-Header of the response to the desired length. Using a Body with...
Read more >Retrofit2 doesn't handle empty content responses - Ken Yee
The workaround is to add a null delegating converter in front of the JSON converter for Retrofit2. class NullOnEmptyConverterFactory implements Converter.
Read more >https://raw.githubusercontent.com/ktorio/ktor/mast...
receiveText() tries to parse body as JSON when the ContentNegotiation plugin is ... Document how to enable/disable HTTP/2 for different client engines ...
Read more >REST Request Test Step | ReadyAPI Documentation
The REST Request test step sends a REST request of the specified type (GET, POST, PUT and so on), gets a response and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think i found a solution I have to set the content-type only when necessary :
Fixed in
1.4.1