Skip to content

Commit

Permalink
Switch to getQueryString - removes length change exception
Browse files Browse the repository at this point in the history
  • Loading branch information
andywebb1975 committed May 5, 2024
1 parent 93d2438 commit 5e81b74
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,10 @@ private PreparedRequest preparePutOrPost(
// 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();
// 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());
Expand Down

0 comments on commit 5e81b74

Please sign in to comment.