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 45fa3ee commit 06ee0c4
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,18 @@ 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));
bodyPublisher = HttpRequest.BodyPublishers.ofString(queryParams.toQueryString().substring(1));

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

0 comments on commit 06ee0c4

Please sign in to comment.