Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-6658

SearchHandler should accept POST requests with JSON data in content stream for customized plug-in components



    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1, 4.9, 4.9.1, 4.10, 4.10.1
    • None
    • None


      This issue relates to the following one:
      Return HTTP error on POST requests with no Content-Type

      The original consideration of the above is to make sure that incoming POST requests to SearchHandler have corresponding content-type specified. That is quite reasonable, however, the following lines in the patch cause to reject all POST requests with content stream data, which is not necessary to that issue:

      Index: solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
      --- solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java	(revision 1546817)
      +++ solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java	(working copy)
      @@ -22,9 +22,11 @@
       import java.util.List;
       import org.apache.solr.common.SolrException;
      +import org.apache.solr.common.SolrException.ErrorCode;
       import org.apache.solr.common.params.CommonParams;
       import org.apache.solr.common.params.ModifiableSolrParams;
       import org.apache.solr.common.params.ShardParams;
      +import org.apache.solr.common.util.ContentStream;
       import org.apache.solr.core.CloseHook;
       import org.apache.solr.core.PluginInfo;
       import org.apache.solr.core.SolrCore;
      @@ -165,6 +167,10 @@
           // int sleep = req.getParams().getInt("sleep",0);
           // if (sleep > 0) {log.error("SLEEPING for " + sleep);  Thread.sleep(sleep);}
      +    if (req.getContentStreams() != null && req.getContentStreams().iterator().hasNext()) {
      +      throw new SolrException(ErrorCode.BAD_REQUEST, "Search requests cannot accept content streams");
      +    }
           ResponseBuilder rb = new ResponseBuilder(req, rsp, components);
           if (rb.requestInfo != null) {

      We are using Solr 4.5.1 in our production services and considering to upgrade to 4.9/5.0 to support more features. But due to this issue, we cannot have a chance to upgrade because we have some important customized SearchComponent plug-ins that need to get POST data from SearchHandler to do further processing.

      Therefore, we are requesting if it is possible to remove the content stream constraint shown above and to let SearchHandler accept POST requests with Content-Type: application/json to allow further components to get the data.

      Thank you.

      Best regards,
      Mark Peng


        1. SOLR-6658.patch
          0.8 kB
          Mark Peng
        2. SOLR-6658.patch
          2 kB
          Mark Peng
        3. SOLR-6658.patch
          0.8 kB
          Mark Peng

        Issue Links



              noble.paul Noble Paul
              markpeng Mark Peng
              2 Vote for this issue
              7 Start watching this issue