gerlowskija commented on code in PR #2455: URL: https://github.com/apache/solr/pull/2455#discussion_r1624867836
########## solr/solrj/src/java/org/apache/solr/client/solrj/util/ClientUtils.java: ########## @@ -56,6 +63,51 @@ public static Collection<ContentStream> toContentStreams( return streams; } + /** + * Create the full URL for a SolrRequest (excepting query parameters) as a String + * + * @param solrRequest the {@link SolrRequest} to build the URL for + * @param requestWriter a {@link RequestWriter} from the {@link SolrClient} that will be sending + * the request + * @param serverRootUrl the root URL of the Solr server being targeted. May by overridden {@link + * SolrRequest#getBasePath()}, if present. + * @param collection the collection to send the request to. May be null if no collection is + * needed. + * @throws MalformedURLException if {@code serverRootUrl} or {@link SolrRequest#getBasePath()} + * contain a malformed URL string + */ + public static String buildRequestUrl( + SolrRequest<?> solrRequest, + RequestWriter requestWriter, + String serverRootUrl, + String collection) + throws MalformedURLException { + String basePath = solrRequest.getBasePath() == null ? serverRootUrl : solrRequest.getBasePath(); + + if (solrRequest instanceof V2Request) { + if (System.getProperty("solr.v2RealPath") == null) { + basePath = changeV2RequestEndpoint(basePath); + } else { + basePath = serverRootUrl + "/____v2"; + } + } + + if (solrRequest.requiresCollection() && collection != null) basePath += "/" + collection; + + String path = requestWriter.getPath(solrRequest); Review Comment: Agreed! I didn't tackle that here because, as a public and pluggable class in SolrJ, there are some backcompat implications that I didn't want to drag down this PR with. But I'm all for the change if you want to go for it, or if climbs high enough up my priority list... -- 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