Github user andreaturli commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/715#discussion_r120005612
--- Diff:
core/src/main/java/org/apache/brooklyn/core/effector/http/HttpCommandEffector.java
---
@@ -181,7 +204,19 @@ private HttpRequest buildHttpRequest(String httpVerb,
URI uri, Map<String, Strin
if (contentType == null ||
contentType.equalsIgnoreCase(APPLICATION_JSON)) {
LOG.warn("Content-Type not specified. Using {}, as
default (continuing)", APPLICATION_JSON);
body = toJsonString(payload);
- } else if
(!contentType.equalsIgnoreCase(APPLICATION_JSON)) {
+ } else if
(contentType.equalsIgnoreCase(APPLICATION_X_WWW_FORM_URLENCODE)) {
+ if (payload instanceof Map) {
+ for (Map.Entry<String, String> entry :
((Map<String, String>) payload).entrySet()) {
+ try {
+ if (!body.equals("")) body += "&";
+ body += URLEncoder.encode(entry.getKey(),
StandardCharsets.UTF_8.toString()) + "=" + URLEncoder.encode(entry.getValue(),
StandardCharsets.UTF_8.toString());
--- End diff --
thanks, @geomacy but I think this is the intended behavior.
`URLEncoder.encode` javadoc explicitly says
```
Translates a string into {@code application/x-www-form-urlencoded}
* format using a specific encoding scheme.
```
so I think it is ok, no?
fyi, the `UrlEncoder.encode("<img>")` is `%3Cimg%3E`. I'll add more unit
tests for the encoding anyway.
Am I missing something? thanks
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---