有人知道如何在发出JSON请求时停止缓存吗? 在我的JSON请求标头中,我有用户名和密码,我的问题是:
首先我输入正确的数据(正确的用户名和密码) - >请求成功 从上面的步骤后,我介绍了一个正确的用户名,但错误的密码 - >请求仍然成功,它不应该 然后我用Force Stop关闭我的应用程序并输入错误的密码。 现在请求失败,这是好的。但我不明白为什么我必须强制停止应用程序才能获得请求的正确状态。 我想到的唯一想法就是以某种方式缓存数据。 如果我的想法是正确的,我怎么能阻止缓存? 我将不胜感激!
How can I stop caching when a JSON request is made? In my JSON request headers I have username and password and my problem is:
first I put the correct data (correct username and password) -> The request is successful after the step from above I introduce a correct username but a wrong password -> The request is still successful and it shouldn't then I am closing my app with Force Stop and let the wrong password. Now the request fails which is Ok.But I don't understand why I have to Force Stop the app in order to get the correct status of the request. The only thought that crossed my mind is that somehow the data is cached. If my thoughts are correct how can I prevent the caching?
最满意答案
我已经弄明白问题是什么了。 当我更改密码时,会话未关闭,并且它与旧数据连接。 所以我不得不使用这段代码“注销”:
client.getConnectionManager().closeExpiredConnections(); client = null;然后我创建了一个新的Http客户端。
I have figured it out what the problem was. When I changed the password the session was not closed and it was connecting with the old data. So I had to make a "log out" using this code:
client.getConnectionManager().closeExpiredConnections(); client = null;And then I created a new Http Client.
更多推荐
发布评论