Skip to content

Commit

Permalink
Refactor PUT/POST body
Browse files Browse the repository at this point in the history
  • Loading branch information
andywebb1975 committed May 10, 2024
1 parent 6c6e183 commit 11f4517
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,12 +299,19 @@ private PreparedRequest preparePutOrPost(
InputStream is = streams.iterator().next().getStream();
bodyPublisher = HttpRequest.BodyPublishers.ofInputStream(() -> is);
} else if (queryParams != null && urlParamNames != null) {
ModifiableSolrParams requestParams = queryParams;
queryParams = calculateQueryParams(urlParamNames, requestParams);
queryParams.add(calculateQueryParams(solrRequest.getQueryParams(), requestParams));
// move params specified in urlParamNames from queryParams into urlParams
ModifiableSolrParams urlParams = calculateQueryParams(urlParamNames, queryParams);

// note this is only triggered if urlParamNames is set too - this this correct?
urlParams.add(calculateQueryParams(solrRequest.getQueryParams(), queryParams));

// put the remaining params in the request body
// note the toQueryString() method adds a leading question mark which needs to be removed here
bodyPublisher =
HttpRequest.BodyPublishers.ofString(requestParams.toQueryString().substring(1));

// replace queryParams with the selected set
queryParams = urlParams;
} else {
bodyPublisher = HttpRequest.BodyPublishers.noBody();
}
Expand Down

0 comments on commit 11f4517

Please sign in to comment.