Skip to content

React-Native appends "charset=utf-8" to HTTP call Content-Type #14445

Closed
@laurent22

Description

@laurent22

Description

I'm trying to use the Dropbox API with React-Native but when I try to call filesUpload I'm getting the following error:

Error in call to API function "files/upload": Bad HTTP "Content-Type" header: "application/octet-stream; charset=utf-8".  Expecting one of "application/octet-stream", "text/plain; charset=dropbox-cors-hack".

The Dropbox SDK makes use of the superagent library and it sets up the call like this:

apiRequest = request.post(getBaseURL(host) + path)
  .type('application/octet-stream')
  .set('Authorization', 'Bearer ' + accessToken)
  .set('Dropbox-API-Arg', httpHeaderSafeJson(args));

So the content-type is set to just "application/octet-stream" but when the request is eventually executed it's changed to "application/octet-stream; charset=utf-8". I'm assuming the SDK works fine in Node or in a browser, and that it's something that React-Native is adding. Is it a known issue? Is there any way to go around it?

Solution

Make sure that HTTP calls coming from React-Native do not append ; charset=utf-8 to the Content-Type (or make it optional).

Additional Information

  • React Native version: 0.44
  • Platform: Android (running on emulator under Windows)
  • Development Operating System: Windows 10
  • Dev tools: Android Studio

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugHelp Wanted :octocat:Issues ideal for external contributors.🌐NetworkingRelated to a networking API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions