mirror of https://github.com/apache/lucene.git
SOLR-3388: disable httpCaching for UpdateHandlers by default
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1328535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ab61af4d1d
commit
5ae1d1c1f5
|
@ -500,7 +500,10 @@ Other Changes
|
|||
from org.apache.solr.common to org.apache.solr.util (Chris Male)
|
||||
|
||||
* SOLR-3357: ResourceLoader.newInstance now accepts a Class representation of the expected
|
||||
instance type (Chris Male)
|
||||
instance type (Chris Male)
|
||||
|
||||
* SOLR-3388: HTTP caching is now disabled by default for RequestUpdateHandlers. (ryan)
|
||||
|
||||
|
||||
Documentation
|
||||
----------------------
|
||||
|
|
|
@ -20,11 +20,11 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.params.UpdateParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.response.SolrQueryResponse;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessor;
|
||||
import org.apache.solr.update.processor.UpdateRequestProcessorChain;
|
||||
import org.apache.solr.util.SolrPluginUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,8 +34,22 @@ import org.slf4j.LoggerFactory;
|
|||
*
|
||||
**/
|
||||
public abstract class ContentStreamHandlerBase extends RequestHandlerBase {
|
||||
public static Logger log = LoggerFactory.getLogger(XmlUpdateRequestHandler.class);
|
||||
public static Logger log = LoggerFactory.getLogger(ContentStreamHandlerBase.class);
|
||||
|
||||
@Override
|
||||
public void init(NamedList args) {
|
||||
super.init(args);
|
||||
|
||||
// Caching off by default
|
||||
httpCaching = false;
|
||||
if (args != null) {
|
||||
Object caching = initArgs.get("httpCaching");
|
||||
if(caching!=null) {
|
||||
httpCaching = Boolean.parseBoolean(caching.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception {
|
||||
SolrParams params = req.getParams();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.apache.http.Header;
|
|||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpRequestBase;
|
||||
import org.apache.http.impl.cookie.DateUtils;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -47,7 +48,9 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
|
|||
@Test
|
||||
public void testCacheVetoHandler() throws Exception {
|
||||
File f=makeFile(CONTENTS);
|
||||
HttpRequestBase m=getUpdateMethod("GET", "stream.file", f.getCanonicalPath());
|
||||
HttpRequestBase m=getUpdateMethod("GET",
|
||||
CommonParams.STREAM_FILE, f.getCanonicalPath(),
|
||||
CommonParams.STREAM_CONTENTTYPE, "text/csv" );
|
||||
HttpResponse response = getClient().execute(m);
|
||||
assertEquals(200, response.getStatusLine().getStatusCode());
|
||||
checkVetoHeaders(response, true);
|
||||
|
@ -65,8 +68,8 @@ public class CacheHeaderTest extends CacheHeaderTestBase {
|
|||
protected void checkVetoHeaders(HttpResponse response, boolean checkExpires) throws Exception {
|
||||
Header head = response.getFirstHeader("Cache-Control");
|
||||
assertNotNull("We got no Cache-Control header", head);
|
||||
assertTrue("We got no no-cache in the Cache-Control header", head.getValue().contains("no-cache"));
|
||||
assertTrue("We got no no-store in the Cache-Control header", head.getValue().contains("no-store"));
|
||||
assertTrue("We got no no-cache in the Cache-Control header ["+head+"]", head.getValue().contains("no-cache"));
|
||||
assertTrue("We got no no-store in the Cache-Control header ["+head+"]", head.getValue().contains("no-store"));
|
||||
|
||||
head = response.getFirstHeader("Pragma");
|
||||
assertNotNull("We got no Pragma header", head);
|
||||
|
|
Loading…
Reference in New Issue