[ 
https://issues.apache.org/jira/browse/SOLR-5517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14224664#comment-14224664
 ] 

Mark Peng commented on SOLR-5517:
---------------------------------

Hi Committers,

We had confirmed that posted JSON data are rejected due to the content stream 
constraint ("Search requests cannot accept content streams") added in 
SearchHandler. 

To clarify the related part in this patch:
{code}
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) {
       rb.requestInfo.setResponseBuilder(rb);
{code}

Suppose that the "SearchRequestHandler" mentioned by [~thetaphi] is the same as 
"SearchHandler.java," we would suggest to add content type check before 
determining if it is reasonable to accept content streams. For example, if the 
incoming request is a POST with *Content-Type: application/json*, then it is 
necessary to accept the forwarding of its payload data (stored as content 
streams) to other search components.

Thank you.

Best regards,
Mark Peng




> Return HTTP error on POST requests with no Content-Type
> -------------------------------------------------------
>
>                 Key: SOLR-5517
>                 URL: https://issues.apache.org/jira/browse/SOLR-5517
>             Project: Solr
>          Issue Type: Improvement
>            Reporter: Ryan Ernst
>            Assignee: Ryan Ernst
>             Fix For: 4.7, Trunk
>
>         Attachments: SOLR-5517.patch, SOLR-5517.patch, SOLR-5517.patch, 
> SOLR-5517.patch, SOLR-5517.patch
>
>
> While the http spec states requests without a content-type should be treated 
> as application/octet-stream, the html spec says instead that post requests 
> without a content-type should be treated as a form 
> (http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1).  It would be 
> nice to allow large search requests from html forms, and not have to rely on 
> the browser to set the content type (since the spec says it doesn't have to).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to