-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid adding charset
to Content-Type
header
#1438
Comments
@brianquinlan I will be looking into this issue. |
The documentation for |
@brianquinlan Is it obligatory from http to add charset parameter into the headers? |
"charset" is not required, see https://datatracker.ietf.org/doc/html/rfc2046#section-4.1.2 @samrat I think that your problem is that you are setting the HTTP payload using @seifibrahim32 Changing |
@brianquinlan Yes, charset should be with default utf8 or utf16 atmost. @samrat Have you tried to use |
I am having the same issue here when using an opentelemetry collector. The rules are strict :
Here is my code: http.Response response = await http.post(
Uri.parse(
otelUrl,
),
headers: <String, String>{
"content-type": "application/json",
},
body: jsonBody,
); As I understand, there is no good solution to avoid "charset=utf-8" to be added in content-type node while using http ? We should directly use request instead ? @seifibrahim32 If |
@chedwin41 It seems the way to prevent this behaviour is to set the request body first before setting the headers. Here is what I did: https://samrat.me/til-avoid-modifying-headers-with-dart-http-package/ . Would love to know if there is a better way. |
…e' header This is a fix for `http` dependency issue, see dart-lang/http#1438
Hello! 👋
I'm trying to use the OpenAI Realtime API and need to send
Content-Type: application/sdp
as one of the headers.Here's what my Dart code looks like
Even though I'm setting the header to
application/sdp
the request sent has the header set toapplication/sdp; charset=utf-8
(I tested this with iOS, macOS and Web debug targets)And looks like the OpenAI endpoint is very strict about the value it accepts for this header:
Is there any way to prevent the
http
library from modifying headers before the request is made?The text was updated successfully, but these errors were encountered: