]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9224 HTTP data parts must have filename to allow streaming 2067/head
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 12 May 2017 09:11:06 +0000 (11:11 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 12 May 2017 14:01:39 +0000 (16:01 +0200)
on server side

sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java

index 4092b1a826ce47020817ff55b7cfae708c2ae655..e652a21e28ff0427d7e077517d975879a583256e 100644 (file)
@@ -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.