-2

WebClient urlbuilder query string has changed

String key = "bEyBOCB4SoL%2F1gI%s"

webClient.get()
.scheme("http")
.host("www.localhost:8080")
.queryParam("key", URLEncoder.encode(key, StandardCharsets.UTF_8.toString()))
.build()

... send request

query string has changed "bEyBOCB4SoL%25252F1gI%2525"

origin = "bEyBOCB4SoL%2F1gI%s"

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
javaOne
  • 1
  • 3

1 Answers1

2

You are triple-encoding the value.

  • The key string is already encoded, see the %2F which is the encoded value of /.
  • You then manually encode by calling URLEncoder.encode(...), which will encode % as %25.
  • The queryParam(...) method will then encode again, which will encode % as %25.

The result is the %25252F you see.

Change the code:

String key = "bEyBOCB4SoL/1gI%s";
.queryParam("key", key)

The result will be: bEyBOCB4SoL%2F1gI%25s

Andreas
  • 154,647
  • 11
  • 152
  • 247