Volley不断发送If-Modified-Since
标题。
我需要阻止凌空发送此标头,因为它一直在弄乱第三方服务器的响应。如何阻止凌空发送缓存标头?
答案 0 :(得分:3)
<强>更新强>
在 >data<-as(rules2.sorted, "data.frame")
>test_predict$prob<-predict(spec_q2, newdata=data,type="response")
Error in `$<-.data.frame`(`*tmp*`, "prob", value = c(0.972014164301877, :
replacement has 2800 rows, data has 1
In addition: Warning message:
'newdata' had 26 rows but variables found have 2800 rows
中,您会找到
BasicNetwork.java
所以我认为您可以尝试以下方法之一:
private void addCacheHeaders(Map<String, String> headers, Cache.Entry entry) {
// If there's no cache entry, we're done.
if (entry == null) {
return;
}
if (entry.etag != null) {
headers.put("If-None-Match", entry.etag);
}
if (entry.lastModified > 0) {
Date refTime = new Date(entry.lastModified);
headers.put("If-Modified-Since", DateUtils.formatDate(refTime));
}
}
,例如:setShouldCache(false);
创建自定义jsonObjectRequest.setShouldCache(false);
变量,您将覆盖BasicNetwork
并设置performRequest
变量null或Cache.Entry
,可以尝试以下操作:
entry.lastModified <= 0
END OF UPDATE
IMO您需要覆盖 BasicNetwork basicNetwork = new BasicNetwork(hurlStack) {
@Override
public NetworkResponse performRequest(Request<?> request) throws VolleyError {
request.setCacheEntry(null);
// request.setShouldCache(false);
return super.performRequest(request);
}
};
方法,您可以尝试以下两种方法之一:
getHeaders
或
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headerMap = super.getHeaders();
if (headerMap.containsKey("If-Modified-Since")) {
headerMap.remove("If-Modified-Since");
}
return headerMap;
}
希望这有帮助!