Application Octet Stream Utf8
Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upHave 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
Comments
commented Jun 10, 2017
DescriptionI'm trying to use the Dropbox API with React-Native but when I try to call filesUpload I'm getting the following error: The Dropbox SDK makes use of the superagent library and it sets up the call like this: 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? SolutionMake sure that HTTP calls coming from React-Native do not append Additional Information
|
commented Jun 12, 2017
As this involves a third party library, can you try and reproduce this using |
commented Jun 13, 2017
After some digging, it seems to be related to the okhttp library. I've put my findings in this related issue: I've also added a comment to the okhttp issue but it doesn't look like they are going to fix it: |
commented Jun 22, 2017 • edited
edited
I am having the same issue
I am having the same issue with XHR requests. Charles shows as @laurent22 points out, it's okhttp adding the content not superagent. I didn't realize that okhttp was a java library, not js library. another issue to read is square/okhttp#2099 where they suggest:
I tracked down react native code as far as here https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/network/RequestBodyUtil.java#L123 But i am out of time to figure out further tonight. If i get time over the weekend I'll keep going. |
commented Jul 11, 2017
I have the same issue. Tried using different third party libraries and even RN fetch. It all failed. |
commented Jul 11, 2017
Fixing the server was the simplest solution for me. Thanks @ericwooley |
commented Sep 21, 2017
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
closed this Sep 21, 2017
commented Sep 21, 2017
@hramos , this is still a major issue for me and quite a few others. The Dropbox API still cannot be used from React Native, which prevents me from adding support for it in my app. It would be good if the issue could be re-opened. It's still not working in the latest release candidate and as far as I know there's currently no pull request addressing the issue. |
commented Oct 10, 2017
@hramos , Our server does not prepare api for “utf-8”, and android avd sent requests with “charset=utf-8'. So it cause 500 status error. the issue should be re-opened |
commented Oct 18, 2017
In our react-native application we have the same problem |
commented Oct 31, 2017
same thing here. It's incredible that react native claims to be same core and uses different kind of http request for each platform. It should be same behavior on both sides |
commented Dec 10, 2017
Here's a workaround #13487 (comment) |
commented Dec 20, 2017
For anyone else stuck, here's what I did to get around it.
|
commented Jan 18, 2018
Please can someone solves this bug? Waiting for nextcloud support which isn't developed before closing this bug: http://joplin.cozic.net/ |
commented Jan 19, 2018
@Schonhoffer excellent! @Dubidubiduu try solution from @Schonhoffer it should work. |
referenced this issue Feb 12, 2018
ClosedDropbox synchronisation? #210
added Help Wanted 🌐 Networking labels Mar 9, 2018
referenced this issue Nov 22, 2018
Opengrpc-web react native android got http response at 400 or 500 level #383
removed the Bug Report label Feb 6, 2019
referenced this issue Mar 18, 2019
Closederror 415 when posting to /tokens with content-type appended charset=utf-8 #639
referenced this issue Mar 19, 2019
ClosedRN Issue Triage Group 1 #24028
removed the Type: Bug Report label May 6, 2019
I agree that it's not a breaking change - if it's limited to cases where conneg decides that application/octet-stream
is the appropriate content type and byte[]
is returned.
For context, I'm officially on the record as opposed to putting in more on by default output formatters for specialized scenarios. I was also against Stream
and I don't think that feature gets of ton of usage. We get feedback from all possible sides of every default behavior the framework implements. What's obvious to one person is not always obvious or easier to understand to another - in fact users tell us that their obvious desires are often in conflict. Now in this case I can't imagine another obvious behavior that you'd want (other than base64, which is already a thing) - but if we do this I'm sure we'll find out.
What would change my mind about this is understanding how this is much better than both what we already have (return File(someBytes, 'application/octet-stream')
) - and also much better than the alternatives (suppose we added return Bytes(someBytes)
).
Would we tell everyone to 'do it this way'? Would we change our documentation to say that this is the correct way to return bytes vs File(...)
?
Keep in mind we're talking about the case where user code sets both the content type and returns bytes
So your code either looks like:
OR
OR