From: Sébastien Lesaint Date: Fri, 12 May 2017 09:11:06 +0000 (+0200) Subject: SONAR-9224 HTTP data parts must have filename to allow streaming X-Git-Tag: 6.4-RC1~15 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5f81649d5f7f9eb7f620d2ac49ed4b82d8ae3991;p=sonarqube.git SONAR-9224 HTTP data parts must have filename to allow streaming on server side --- 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.