Skip to content
Permalink
Browse files

Fixed Solr response header duplication when requesting external Solr

  • Loading branch information...
luccioman committed May 18, 2018
1 parent 124cc24 commit c4d984cec8f0048344e1ebda1414e4276cf3481d
Showing with 20 additions and 6 deletions.
  1. +20 −6 source/net/yacy/http/servlets/SolrSelectServlet.java
@@ -318,13 +318,27 @@ public void run() {
req = new SolrQueryRequestBase(null, mmsp) {};

rsp = new SolrQueryResponse();
NamedList<Object> responseHeader = new SimpleOrderedMap<Object>();
responseHeader.add("params", mmsp.toNamedList());
rsp.add("responseHeader", responseHeader);
rsp.setHttpCaching(false);
rsp.getValues().addAll(queryRsp.getResponse());


rsp.setAllValues(queryRsp.getResponse());

if(!mmsp.getBool(CommonParams.OMIT_HEADER, false)) {
NamedList<Object> responseHeader = rsp.getResponseHeader();
if (responseHeader == null) {
/* The remote Solr provided no response header ? Not likely to happen but let's add one */
responseHeader = new SimpleOrderedMap<Object>();
responseHeader.add("params", mmsp.toNamedList());
rsp.addResponseHeader(responseHeader);
} else {
final int paramsIndex = responseHeader.indexOf("params", 0);
if (paramsIndex >= 0) {
/* Write this Solr servlet initial params to the response header and not the params sent to the remote Solr that differ a little (notably the wt param) */
responseHeader.setVal(paramsIndex, mmsp.toNamedList());
} else {
responseHeader.add("params", mmsp.toNamedList());
}
}
}

// prepare response
hresponse.setHeader("Cache-Control", "no-cache, no-store");

0 comments on commit c4d984c

Please sign in to comment.
You can’t perform that action at this time.