0

我在从 http 请求中检索数据时遇到问题。对于一些服务器请求,解析来自服务器的内容需要一分钟。请求中的数据是一个简短的 json 消息(存储在答案字符串中),因此不必花费这么长时间。

我在 android 中使用 org.apache 库

这只发生在我们生产中的 nginx 服务器上,而不是我的开发 webrick 服务器上(是的,它是一个 rails api)

此代码用于我们所有 api 意图的超类中,但它仅在某些情况下很慢(一些 api 请求)

代码挂在第三行的toString方法上

HttpResponse result = ... ;
HttpEntity response = result.getEntity();
String answer = EntityUtils.toString(response);

这是个常见的问题吗?

编辑:这些是wireshark日志 https://img.skitch.com/20120426-jddnkdbhuttfujym9u4m7a2ph1.jpg

4

1 回答 1

0

好的各位,问题解决了

毕竟是服务器问题,在 Rails 代码中,别忘了添加你的状态码

我们有:

respond_with({:auth_token => current_user.authentication_token}, :location => nil)

这修复了它:

respond_with({:auth_token => current_user.authentication_token},:status => :ok, :location => nil)
于 2012-04-27T09:41:49.713 回答