andywebb1975 commented on code in PR #2433:
URL: https://github.com/apache/solr/pull/2433#discussion_r1596930729
##########
solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpJdkSolrClient.java:
##########
@@ -299,10 +299,23 @@ private PreparedRequest preparePutOrPost(
InputStream is = streams.iterator().next().getStream();
bodyPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> is);
} else if (queryParams != null && urlParamNames != null) {
+ // rP is a new name for the incoming qP
ModifiableSolrParams requestParams = queryParams;
+ // qP becomes a new object, with selected params moved from original set
- when would urlParamNames be specified?
queryParams = calculateQueryParams(urlParamNames, requestParams);
+ // qP gains further (?) params moved from original set if solrRequest
has params, but only if urlParamNames was set too
queryParams.add(calculateQueryParams(solrRequest.getQueryParams(),
requestParams));
- bodyPublisher =
HttpRequest.BodyPublishers.ofString(requestParams.toString());
+ // bP receives any remaining params from original set
+ // with this version the params are not fully encoded - we get raw
Unicode chars, curly braces etc
+ // and the body content length changes, presumably due to re-encoding
+ // String bodyQueryString = requestParams.toString();
+ // with this version the params are fully encoded - note the
toQueryString() method adds an unwanted leading question mark
+ // but there's no longer a length change as the query is fully encoded
before being given to HttpRequest
+ String bodyQueryString = requestParams.toQueryString().substring(1);
+ bodyPublisher = HttpRequest.BodyPublishers.ofString(bodyQueryString);
+ // this isn't intended to be merged - but it shows the content length
change noted above
+ if (bodyQueryString.length() != bodyPublisher.contentLength()) throw new
URISyntaxException("inconsistent content length", bodyQueryString + " - " +
bodyQueryString.length() + " -> " + bodyPublisher.contentLength());
Review Comment:
yes, done!
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]