stillalex commented on code in PR #1789:
URL: https://github.com/apache/solr/pull/1789#discussion_r1286170112


##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java:
##########
@@ -659,62 +633,97 @@ private Request createRequest(SolrRequest<?> solrRequest, 
String collection)
         basePath = serverBaseUrl + "/____v2";
       }
     }
+    String path = requestWriter.getPath(solrRequest);
+    if (path == null || !path.startsWith("/")) {
+      path = DEFAULT_PATH;
+    }
+
+    return basePath + path;
+  }
+
+  private Request makeRequestAndSend(
+      SolrRequest<?> solrRequest, String url, InputStreamResponseListener 
listener, boolean isAsync)
+      throws IOException, SolrServerException {
+
+    // TODO add invariantParams support
+    ResponseParser parser =
+        solrRequest.getResponseParser() == null ? this.parser : 
solrRequest.getResponseParser();
+
+    // The parser 'wt=' and 'version=' params are used instead of the original
+    // params
+    ModifiableSolrParams wparams = new 
ModifiableSolrParams(solrRequest.getParams());
+    wparams.set(CommonParams.WT, parser.getWriterType());
+    wparams.set(CommonParams.VERSION, parser.getVersion());
 
     if (SolrRequest.METHOD.GET == solrRequest.getMethod()) {
-      if (streams != null || contentWriter != null) {
+      RequestWriter.ContentWriter contentWriter = 
requestWriter.getContentWriter(solrRequest);
+      Collection<ContentStream> streams =
+          contentWriter == null ? requestWriter.getContentStreams(solrRequest) 
: null;
+      if (contentWriter != null || streams != null) {
         throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "GET 
can't send streams!");
       }
-
-      return httpClient
-          .newRequest(basePath + path + wparams.toQueryString())
-          .method(HttpMethod.GET);
+      var r = httpClient.newRequest(url + 
wparams.toQueryString()).method(HttpMethod.GET);
+      decorateRequest(r, solrRequest, isAsync);
+      r.send(listener);
+      return r;
     }
 
     if (SolrRequest.METHOD.DELETE == solrRequest.getMethod()) {
-      return httpClient
-          .newRequest(basePath + path + wparams.toQueryString())
-          .method(HttpMethod.DELETE);
+      var r = httpClient.newRequest(url + 
wparams.toQueryString()).method(HttpMethod.DELETE);
+      decorateRequest(r, solrRequest, isAsync);
+      r.send(listener);
+      return r;
     }
 
     if (SolrRequest.METHOD.POST == solrRequest.getMethod()
         || SolrRequest.METHOD.PUT == solrRequest.getMethod()) {
+      RequestWriter.ContentWriter contentWriter = 
requestWriter.getContentWriter(solrRequest);
+      Collection<ContentStream> streams =
+          contentWriter == null ? requestWriter.getContentStreams(solrRequest) 
: null;
 
-      String url = basePath + path;
-      boolean hasNullStreamName = false;
+      boolean isMultipart = false;
       if (streams != null) {
+        boolean hasNullStreamName = false;
         hasNullStreamName = streams.stream().anyMatch(cs -> cs.getName() == 
null);
+        isMultipart = !hasNullStreamName && streams.size() > 1;
       }
 
-      boolean isMultipart = streams != null && streams.size() > 1 && 
!hasNullStreamName;
-
       HttpMethod method =
           SolrRequest.METHOD.POST == solrRequest.getMethod() ? HttpMethod.POST 
: HttpMethod.PUT;
 
       if (contentWriter != null) {
-        Request req = httpClient.newRequest(url + 
wparams.toQueryString()).method(method);
-        Utils.BAOS baos = new Utils.BAOS();
-        contentWriter.write(baos);
-
-        // SOLR-16265: TODO reduce memory usage
-        return req.content(
-            // We're throwing this BAOS away, so no need to copy the byte[], 
just use the raw buf
-            new ByteBufferContentProvider(
-                contentWriter.getContentType(), ByteBuffer.wrap(baos.getbuf(), 
0, baos.size())));
+        OutputStreamRequestContent content =

Review Comment:
   agreed. I added a few of those below, this one got away. replaced it with 
latest commit



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to