Skip to content

Commit

Permalink
Add body length change check - triggers exception
Browse files Browse the repository at this point in the history
  • Loading branch information
andywebb1975 committed May 5, 2024
1 parent ce36e81 commit 545e668
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,11 @@ private PreparedRequest preparePutOrPost(
// 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));
// 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
// 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();
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());
// qP has been replaced with params moved from original set
} else {
bodyPublisher = HttpRequest.BodyPublishers.noBody();
Expand Down

0 comments on commit 545e668

Please sign in to comment.