Merge pull request #78 from shikui/master

1、将http 304作为正常状态处理;2、应为ETag,而不是ETags
This commit is contained in:
Medcl 2015-08-04 11:50:39 +08:00
commit 7dcffada95
2 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@
</parent> </parent>
<properties> <properties>
<elasticsearch.version>1.6.0</elasticsearch.version> <elasticsearch.version>1.6.2</elasticsearch.version>
</properties> </properties>
<repositories> <repositories>

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() );