Author: kwright
Date: Fri Sep 21 14:44:29 2018
New Revision: 1841596

URL: http://svn.apache.org/viewvc?rev=1841596&view=rev
Log:
CONNECTORS-1533: Add a hack that uses the URL length to determine what kind of 
request to transmit.  This is obviously not ideal.  There is an open post to 
the [email protected] group requesting clarity about how this should be 
done.

Modified:
    
manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrClient.java

Modified: 
manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrClient.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrClient.java?rev=1841596&r1=1841595&r2=1841596&view=diff
==============================================================================
--- 
manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrClient.java
 (original)
+++ 
manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/ModifiedHttpSolrClient.java
 Fri Sep 21 14:44:29 2018
@@ -145,6 +145,14 @@ public class ModifiedHttpSolrClient exte
     if (SolrRequest.METHOD.POST == request.getMethod() || 
SolrRequest.METHOD.PUT == request.getMethod()) {
 
       String url = basePath + path;
+      
+      // Hack to allow short queries to go one way, and long queries to go 
another.
+      final String wQueryString = toQueryString(wparams, false);
+      final boolean mustUseMultipart = url.length() + wQueryString.length() > 
4000;
+      if (mustUseMultipart) {
+        streams = requestWriter.getContentStreams(request);
+      }
+      
       boolean hasNullStreamName = false;
       if (streams != null) {
         for (ContentStream cs : streams) {
@@ -158,8 +166,8 @@ public class ModifiedHttpSolrClient exte
           || (streams != null && streams.size() > 1)) && !hasNullStreamName;
 
       LinkedList<NameValuePair> postOrPutParams = new LinkedList<>();
-      if(contentWriter != null) {
-        String fullQueryUrl = url + toQueryString(wparams, false);
+      if(contentWriter != null && !mustUseMultipart) {
+        String fullQueryUrl = url + wQueryString;
         HttpEntityEnclosingRequestBase postOrPut = SolrRequest.METHOD.POST == 
request.getMethod() ?
             new HttpPost(fullQueryUrl) : new HttpPut(fullQueryUrl);
         postOrPut.addHeader("Content-Type",


Reply via email to