/api/v1 returns application/json; charset=utf8
instead of utf-8
#14511
Labels
application/json; charset=utf8
instead of utf-8
#14511
Uh oh!
There was an error while loading. Please reload this page.
Description
When decoding the response from https://try.gitea.io/api/v1/version with .NET code
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
an exception is thrown because the charsetutf8
is invalid. The Gitea test server responds with the following HTTP headers:According to the W3C, which is referring to the IANA the charset is specified as
UTF-8
. When manually modifying the received header toapplication/json; charset=utf-8
, decoding works fine and no exception is thrown.When working with my local test server, which is behind a reverse-proxy, the API is also working fine, because the proxy is "sanitizing" the character set:
If you agree with my observation that the charset should be
UTF-8
orutf-8
(containing a dash), please consider changing the character set for one of the upcoming releases to be standard compliant.Without any further knowledge about Gitea or golang, two of the possibly affected locations are:
gitea/modules/context/context.go
Line 359 in 99b7af6
gitea/modules/context/context.go
Line 324 in 99b7af6
The text was updated successfully, but these errors were encountered: