You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an encoding issue when consuming the web service using the Flutter/Dart HTTP client. The client seems to default to latin1 encoding when the Content-Type header lacks a specified charset, resulting in misinterpreted special characters.
Impact
This issue impacts any client that relies on the Content-Type header to determine the correct character encoding. Since the Flutter/Dart HTTP client defaults to latin1, it incorrectly decodes responses that include special characters, assuming the absence of a charset=utf-8 in the Content-Type header.
Steps to Reproduce
Consume the API endpoint using Flutter/Dart HTTP client.
Notice special characters are not displayed correctly.
Proposed Solution
To resolve this issue, I suggest explicitly setting the charset in the Content-Type header for JSON responses. This can be implemented in the _process_api_query function.
fromfastapi.responsesimportJSONResponse# Modify the _process_api_query function to return a JSONResponse with charset=utf-8ifnotuse_csv:
returnJSONResponse(content=results, media_type="application/json; charset=utf-8")
else:
# Existing CSV handling logic
By specifying charset=utf-8 in the Content-Type header, clients like Flutter/Dart should correctly interpret the response encoding as UTF-8.
The text was updated successfully, but these errors were encountered:
Issue Description
I've encountered an encoding issue when consuming the web service using the Flutter/Dart HTTP client. The client seems to default to
latin1
encoding when theContent-Type
header lacks a specified charset, resulting in misinterpreted special characters.Impact
This issue impacts any client that relies on the
Content-Type
header to determine the correct character encoding. Since the Flutter/Dart HTTP client defaults tolatin1
, it incorrectly decodes responses that include special characters, assuming the absence of acharset=utf-8
in theContent-Type
header.Steps to Reproduce
Proposed Solution
To resolve this issue, I suggest explicitly setting the charset in the
Content-Type
header for JSON responses. This can be implemented in the_process_api_query
function.By specifying charset=utf-8 in the Content-Type header, clients like Flutter/Dart should correctly interpret the response encoding as UTF-8.
The text was updated successfully, but these errors were encountered: