Skip to content
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

Open
samrat opened this issue Dec 26, 2024 · 0 comments
Open

Avoid adding charset to Content-Type header #1438

samrat opened this issue Dec 26, 2024 · 0 comments
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@samrat
Copy link

samrat commented Dec 26, 2024

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

      final response = await http.post(
        Uri.parse('$baseUrl?model=$model'),
        headers: {
          'Authorization': 'Bearer $ephemeralKey',
          'Content-Type': 'application/sdp',
        },
        body: sdp,
        encoding: null
      );

Even though I'm setting the header to application/sdp the request sent has the header set to application/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:

Response body: {"error":{"message":"Unsupported content type. This API method only accepts 'application/sdp' requests, but you specified the header 'Content-Type: application/sdp; charset=utf-8'. Please try again with a supported content type.","type":"invalid_request_error","param":null,"code":"unsupported_content_type"}}

Is there any way to prevent the http library from modifying headers before the request is made?

@samrat samrat added package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:http type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

1 participant