mirror of https://github.com/apache/lucene.git
SOLR-746 -- Added "omitHeader" request parameter to omit the header from the response
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@706577 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fa8ca41a71
commit
9c0c4a1621
|
@ -67,6 +67,9 @@ New Features
|
|||
as well as configuration replication and exposes detailed statistics and progress information
|
||||
on the Admin page. Works on all platforms. (Noble Paul, yonik, Akshay Ukey, shalin)
|
||||
|
||||
10. SOLR-746: Added "omitHeader" request parameter to omit the header from the response.
|
||||
(Noble Paul via shalin)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
1. SOLR-374: Use IndexReader.reopen to save resources by re-using parts of the
|
||||
|
|
|
@ -90,6 +90,9 @@ public interface CommonParams {
|
|||
/** include the parameters in the header **/
|
||||
public static final String HEADER_ECHO_PARAMS = "echoParams";
|
||||
|
||||
/** include header in the response */
|
||||
public static final String OMIT_HEADER = "omitHeader";
|
||||
|
||||
/** valid values for: <code>echoParams</code> */
|
||||
public enum EchoParamStyle {
|
||||
EXPLICIT,
|
||||
|
|
|
@ -287,4 +287,10 @@ public class NamedList<T> implements Cloneable, Serializable, Iterable<Map.Entry
|
|||
};
|
||||
return iter;
|
||||
}
|
||||
|
||||
public T remove(String name) {
|
||||
int idx = indexOf(name, 0);
|
||||
if(idx != -1) return remove(idx);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.lucene.document.Fieldable;
|
|||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.NamedListCodec;
|
||||
import org.apache.solr.schema.IndexSchema;
|
||||
|
@ -40,6 +41,8 @@ import java.util.*;
|
|||
public class BinaryResponseWriter implements BinaryQueryResponseWriter {
|
||||
public void write(OutputStream out, SolrQueryRequest req, SolrQueryResponse response) throws IOException {
|
||||
Resolver resolver = new Resolver(req, response.getReturnFields());
|
||||
Boolean omitHeader = req.getParams().getBool(CommonParams.OMIT_HEADER);
|
||||
if(omitHeader != null && omitHeader) response.getValues().remove("responseHeader");
|
||||
NamedListCodec codec = new NamedListCodec(resolver);
|
||||
codec.marshal(response.getValues(), out);
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
import org.apache.solr.schema.SchemaField;
|
||||
|
@ -85,6 +86,8 @@ class JSONWriter extends TextResponseWriter {
|
|||
if(wrapperFunction!=null) {
|
||||
writer.write(wrapperFunction + "(");
|
||||
}
|
||||
Boolean omitHeader = req.getParams().getBool(CommonParams.OMIT_HEADER);
|
||||
if(omitHeader != null && omitHeader) rsp.getValues().remove("responseHeader");
|
||||
writeNamedList(null, rsp.getValues());
|
||||
if(wrapperFunction!=null) {
|
||||
writer.write(')');
|
||||
|
|
|
@ -99,6 +99,8 @@ final public class XMLWriter {
|
|||
|
||||
// dump response values
|
||||
NamedList lst = rsp.getValues();
|
||||
Boolean omitHeader = req.getParams().getBool(CommonParams.OMIT_HEADER);
|
||||
if(omitHeader != null && omitHeader) lst.remove("responseHeader");
|
||||
int sz = lst.size();
|
||||
int start=0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue