private String getNotModified(String dataId, CacheData cacheData, HttpMethod httpMethod) { Header md5Header = httpMethod.getResponseHeader(Constants.CONTENT_MD5); if (null == md5Header) { throw new RuntimeException("RP_NO_CHANGE response not contain MD5"); } String md5 = md5Header.getValue(); if (!cacheData.getMd5().equals(md5)) { String lastMd5 = cacheData.getMd5(); cacheData.setMd5(Constants.NULL); cacheData.setLastModifiedHeader(Constants.NULL); throw new RuntimeException( "MD5 verify error,DataID:[" + dataId + "]MD5 last:[" + lastMd5 + "]MD5 current:[" + md5 + "]"); } cacheData.setMd5(md5); changeSpacingInterval(httpMethod); if (log.isInfoEnabled()) { log.info("DataId: " + dataId + ",not changed"); } return null; }
private void configureHttpMethod( boolean skipContentCache, CacheData cacheData, long onceTimeOut, HttpMethod httpMethod) { if (skipContentCache && null != cacheData) { if (null != cacheData.getLastModifiedHeader() && Constants.NULL != cacheData.getLastModifiedHeader()) { httpMethod.addRequestHeader(Constants.IF_MODIFIED_SINCE, cacheData.getLastModifiedHeader()); } if (null != cacheData.getMd5() && Constants.NULL != cacheData.getMd5()) { httpMethod.addRequestHeader(Constants.CONTENT_MD5, cacheData.getMd5()); } } httpMethod.addRequestHeader(Constants.ACCEPT_ENCODING, "gzip,deflate"); HttpMethodParams params = new HttpMethodParams(); params.setSoTimeout((int) onceTimeOut); httpMethod.setParams(params); httpClient .getHostConfiguration() .setHost( diamondConfigure.getDomainNameList().get(this.domainNamePos.get()), diamondConfigure.getPort()); }