1、将http 304作为正常状态处理;2、应为ETag,而不是ETags

1、将http 304作为正常状态处理,避免大量304错误写到日志文件里;2、应为ETag,而不是ETags
This commit is contained in:
shikui 2015-08-03 17:46:23 +08:00
parent 2f367029e4
commit 2cbd91c6c0

View File

@ -62,15 +62,15 @@ public class Monitor implements Runnable {
response = httpclient.execute(head); response = httpclient.execute(head);
//返回200 才做操作 //返回200 才做操作
if(response.getStatusLine().getStatusCode()==200){ if(response.getStatusLine().getStatusCode()==200 || response.getStatusLine().getStatusCode()==304){
if (!response.getLastHeader("Last-Modified").getValue().equalsIgnoreCase(last_modified) if (!response.getLastHeader("Last-Modified").getValue().equalsIgnoreCase(last_modified)
||!response.getLastHeader("ETags").getValue().equalsIgnoreCase(eTags)) { ||!response.getLastHeader("ETag").getValue().equalsIgnoreCase(eTags)) {
// 远程词库有更新,需要重新加载词典并修改last_modified,eTags // 远程词库有更新,需要重新加载词典并修改last_modified,eTags
Dictionary.getSingleton().reLoadMainDict(); Dictionary.getSingleton().reLoadMainDict();
last_modified = response.getLastHeader("Last-Modified")==null?null:response.getLastHeader("Last-Modified").getValue(); last_modified = response.getLastHeader("Last-Modified")==null?null:response.getLastHeader("Last-Modified").getValue();
eTags = response.getLastHeader("ETags")==null?null:response.getLastHeader("ETags").getValue(); eTags = response.getLastHeader("ETag")==null?null:response.getLastHeader("ETag").getValue();
} }
}else{ }else{
Dictionary.logger.info("remote_ext_dict {} return bad code {}" , location , response.getStatusLine().getStatusCode() ); Dictionary.logger.info("remote_ext_dict {} return bad code {}" , location , response.getStatusLine().getStatusCode() );