From 5f81649d5f7f9eb7f620d2ac49ed4b82d8ae3991 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Fri, 12 May 2017 11:11:06 +0200 Subject: [PATCH] SONAR-9224 HTTP data parts must have filename to allow streaming on server side --- .../main/java/org/sonarqube/ws/client/HttpConnector.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java index 4092b1a826c..e652a21e28f 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java @@ -25,11 +25,9 @@ import java.util.Map; import javax.annotation.Nullable; import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.X509TrustManager; - import okhttp3.Call; import okhttp3.Credentials; import okhttp3.FormBody; -import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.MediaType; import okhttp3.MultipartBody; @@ -134,8 +132,9 @@ public class HttpConnector implements WsConnector { MultipartBody.Builder bodyBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); parts.entrySet().forEach(param -> { PostRequest.Part part = param.getValue(); - bodyBuilder.addPart( - Headers.of("Content-Disposition", format("form-data; name=\"%s\"", param.getKey())), + bodyBuilder.addFormDataPart( + param.getKey(), + part.getFile().getName(), RequestBody.create(MediaType.parse(part.getMediaType()), part.getFile())); }); body = bodyBuilder.build(); @@ -247,7 +246,7 @@ public class HttpConnector implements WsConnector { this.connectTimeoutMs = i; return this; } - + /** * Optional SSL socket factory with which SSL sockets will be created to establish SSL connections. * If not set, a default SSL socket factory will be used, base d on the JVM's default key store. -- 2.39.5