- String encoded = command.replace(" ", "+").replace("#", "%23")
- .replace("|", "%7C").replace(";", "%3B");
- commands.add(new BasicNameValuePair("command", encoded));
+ String method = getHttpRequestMethod();
+ if ("GET".equals(method))
+ {
+ try
+ {
+ command = URLEncoder.encode(command, StandardCharsets.UTF_8.name());
+ } catch (UnsupportedEncodingException e)
+ {
+ command = command.replace(" ", "+").replace("#", "%23")
+ .replace("|", "%7C").replace(";", "%3B")
+ .replace(":", "%3A");
+ }
+ }
+ commands.add(new BasicNameValuePair("command", command));