From 1852802502d07d9815cd40272e9db588e046308f Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 16 Jul 2013 16:08:55 +0200 Subject: SONAR-4506 Java WS Client - do not use URL query parameters for POST requests --- .../java/org/sonar/wsclient/internal/HttpRequestFactory.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sonar-ws-client/src/main/java') 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 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 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; } } -- cgit v1.2.3