ETag and loadDataFromNetwork()

225 views
Skip to first unread message

Antoine ARNOULT

unread,
Mar 27, 2013, 4:25:44 AM3/27/13
to robo...@googlegroups.com

I use RS with google http client. In my app, i want to receive differents status code (by using ETag) but the loadDataFromNetwork() detects a problem when the server sends a 304. In these conditions, my request goes into the onRequestFailure() function whereas i would load data from cache if i receive a 304. What is the best way to do this ?
Message has been deleted

Antoine ARNOULT

unread,
Mar 27, 2013, 5:51:41 AM3/27/13
to robo...@googlegroups.com
I precise. The code is based on sample robospice-sample-google-http-client. I investigate the error and if i try catch the loadDataFromNetwork(), i can see the error is triggered when i do : 

HttpResponse response = request.execute(); 

and before i call 

response.parseAs(getResultType()) !

Stéphane Nicolas

unread,
Mar 30, 2013, 4:24:27 AM3/30/13
to robo...@googlegroups.com
Hi Antoine,

I believe that you could find a workaround using getFromCacheAndLoadFromNetworkIfExpired from the master branch.

This method will give you what's in cache. If it is considered expired, then it will try to loadDataFromNetwork. Then it could just fail due to 304 error and you would have data from cache.



2013/3/27 Antoine ARNOULT <arnoult...@gmail.com>

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes RoboSpice.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse robospice+...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .
 
 



--
Stéphane NICOLAS,
OCTO Technology 
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - blog.octo.com
www.usievents.com
...........................................................

Antoine ARNOULT

unread,
Apr 2, 2013, 4:21:18 PM4/2/13
to robo...@googlegroups.com

Hello Stephane,

Finally, i've decided to use robospice without google api client. I use my own code (using HttpURLConnection) and i don't use the science of googlers :) ! This way lets me to solve my problem. I'm not sure that is the best solution but i'm too busy and i haven't the time to look for a best way or loose some time to learn a new library. 

Stéphane Nicolas

unread,
Apr 7, 2013, 4:04:03 AM4/7/13
to robo...@googlegroups.com
Hi Antoine,

sorry for the late delay. I am glad it could work for you.

Stéphane


2013/4/2 Antoine ARNOULT <arnoult...@gmail.com>

Adam Mackler

unread,
Apr 20, 2013, 1:53:06 PM4/20/13
to robo...@googlegroups.com
Using spring-android is another alternative to the google client.  If it's heavier, it's more stable (out of beta at least).


On Tuesday, April 2, 2013 4:21:18 PM UTC-4, Antoine ARNOULT wrote:

Hello Stephane,

Finally, i've decided to use robospice without google api client. I use my own code (using HttpURLConnection) 

--
Adam Mackler
 

Antoine ARNOULT

unread,
Apr 20, 2013, 2:08:50 PM4/20/13
to robo...@googlegroups.com

Thx for the comment. I know i can use spring android (I've never used it) with robospice but i didn't want to lose more time to learn how to use spring-android so i decide to create my own client. 

Furthermore, I'm not sure using spring-android can solve my problem. With my own solution, I haven't problem anymore.
Reply all
Reply to author
Forward
0 new messages