Write form data without charset parameter

This commit updates the content-type for form data to not include the
charset, unless it is different from the default charset.

Some servers don't handle charset parameter and the spec is unclear.

See gh-31781
This commit is contained in:
rstoyanchev
2023-12-07 12:12:04 +00:00
committed by Stéphane Nicoll
parent 08998376cc
commit b8715811f8
8 changed files with 44 additions and 53 deletions

View File

@@ -136,8 +136,7 @@ class KotlinRestTemplateHttpServiceProxyTests {
testService.postForm(map)
val request = server.takeRequest()
assertThat(request.headers["Content-Type"])
.isEqualTo("application/x-www-form-urlencoded;charset=UTF-8")
assertThat(request.headers["Content-Type"]).isEqualTo("application/x-www-form-urlencoded")
assertThat(request.body.readUtf8()).isEqualTo("param1=value+1&param2=value+2")
}