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
The http module in nativescript apparently doesn't support basic things like gzip (at least on Android). I have a server that by default is sending a gzipped response (to save major bandwidth as the data is rather large) and of course then the http module will die a horribile death and throw a Java EOF error.
This is actually something that is very surprising that it is totally broken in NS as anything mobile we want to save the amount of data being transferred. So by default we should be supporting http data compression.
If anyone else runs into this issue; you can send the header: accept-encoding: identity which will force it to be a text based uncompressed stream protocol.
We may research whether the okhttp library for Android already handles this. Relates to NativeScript/android#209. Probably a custom http plugin that enables okhttp would be a viable solution.
Yes - we should check this as and provide a recommended way for consumption of "zipped" http content in NativeScript as this really will increase the perf of the app. cc: @enchev
Technically you/we can add support even know in our JavaScript wrapper or simply in the application using this approach however in this case unzipping will be in the UI thread.
Activity
atanasovg commentedon Jan 5, 2016
We may research whether the okhttp library for Android already handles this. Relates to NativeScript/android#209. Probably a custom http plugin that enables okhttp would be a viable solution.
valentinstoychev commentedon Jan 6, 2016
Yes - we should check this as and provide a recommended way for consumption of "zipped" http content in NativeScript as this really will increase the perf of the app. cc: @enchev
enchev commentedon Jan 14, 2016
Technically you/we can add support even know in our JavaScript wrapper or simply in the application using this approach however in this case unzipping will be in the UI thread.
We plan to move our Android HTTP implementation from the runtime to separate plugin similar to widgets where we can add this functionality and our modules will depend on the new Async module similar again to widgets.
What do you think about this plan? :)
jacargentina commentedon Feb 20, 2017
@enchev On iOS i have no problem with the gzip response. Seems to be related only to the Android. Any news on this?
mshanak commentedon Mar 12, 2017
you can use nativescript http with angular , following example:
first import http serves in the top of the service component
var http = require("http");in the sevice.ts file ,you need to convert the http promise to observable .
then you can subscribe to the observeable as you used befor,
Note : now you can remove the import statment of angular http since its not needed
dzfweb commentedon Apr 6, 2017
@mshanak still not working, even using your sample code.
SyntaxError: Unexpected token < in JSON at position 0mshanak commentedon Apr 6, 2017
This is my news.service.ts
and this is how i consume this service
it should work
NathanaelA commentedon Jul 12, 2018
NickIliev commentedon Aug 6, 2018
Closed via NativeScript/tns-core-modules-widgets#128
lock commentedon Aug 26, 2019
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.