aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/main/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-07-16 16:08:55 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-07-16 16:09:03 +0200
commit1852802502d07d9815cd40272e9db588e046308f (patch)
tree19804fd81cd975efb021b3ee5a7de5c3d7553056 /sonar-ws-client/src/main/java
parent8b70b5a5947aa6840e258904c21d3534cd61e168 (diff)
downloadsonarqube-1852802502d07d9815cd40272e9db588e046308f.tar.gz
sonarqube-1852802502d07d9815cd40272e9db588e046308f.zip
SONAR-4506 Java WS Client - do not use URL query parameters for POST requests
Diffstat (limited to 'sonar-ws-client/src/main/java')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
index 19b604884c0..184559fcde4 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
@@ -117,20 +117,19 @@ public class HttpRequestFactory {
}
public String get(String wsUrl, Map<String, Object> queryParams) {
- HttpRequest request = HttpRequest.get(baseUrl + wsUrl, queryParams, true);
+ HttpRequest request = prepare(HttpRequest.get(baseUrl + wsUrl, queryParams, true));
return execute(request);
}
public String post(String wsUrl, Map<String, Object> queryParams) {
- HttpRequest request = HttpRequest.post(baseUrl + wsUrl, queryParams, true);
+ HttpRequest request = prepare(HttpRequest.post(baseUrl + wsUrl, true)).form(queryParams, HttpRequest.CHARSET_UTF8);
return execute(request);
}
private String execute(HttpRequest request) {
try {
- prepare(request);
if (request.ok()) {
- return request.body("UTF-8");
+ return request.body(HttpRequest.CHARSET_UTF8);
}
// TODO handle error messages
throw new HttpException(request.url().toString(), request.code());
@@ -140,7 +139,7 @@ public class HttpRequestFactory {
}
}
- private void prepare(HttpRequest request) {
+ private HttpRequest prepare(HttpRequest request) {
if (proxyHost != null) {
request.useProxy(proxyHost, proxyPort);
if (proxyLogin != null) {
@@ -159,5 +158,6 @@ public class HttpRequestFactory {
if (login != null) {
request.basic(login, password);
}
+ return request;
}
}