Skip to content

Commit 4b3b893

Browse files
committed
update custom MultipartBody to use MediaType.parse() method instead ofof depending the MediaType.get() in okhttp 3.11.0 and higher version.
1 parent 2cc8098 commit 4b3b893

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

library/library.iml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
8585
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
87+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
8788
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
8889
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
8990
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
@@ -101,7 +102,7 @@
101102
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
102103
<orderEntry type="sourceFolder" forTests="false" />
103104
<orderEntry type="library" exported="" name="Gradle: com.google.code.findbugs:jsr305:3.0.2@jar" level="project" />
104-
<orderEntry type="library" exported="" name="Gradle: com.squareup.okio:okio:1.14.0@jar" level="project" />
105-
<orderEntry type="library" exported="" name="Gradle: com.squareup.okhttp3:okhttp:3.11.0@jar" level="project" />
105+
<orderEntry type="library" exported="" name="Gradle: com.squareup.okhttp3:okhttp:3.8.1@jar" level="project" />
106+
<orderEntry type="library" exported="" name="Gradle: com.squareup.okio:okio:1.13.0@jar" level="project" />
106107
</component>
107108
</module>

library/src/main/java/com/qiniu/android/http/MultipartBody.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,34 +39,34 @@ public final class MultipartBody extends RequestBody {
3939
* need to be bundled in a particular order. Any "multipart" subtypes that an implementation does
4040
* not recognize must be treated as being of subtype "mixed".
4141
*/
42-
public static final MediaType MIXED = MediaType.get("multipart/mixed");
42+
public static final MediaType MIXED = MediaType.parse("multipart/mixed");
4343

4444
/**
4545
* The "multipart/alternative" type is syntactically identical to "multipart/mixed", but the
4646
* semantics are different. In particular, each of the body parts is an "alternative" version of
4747
* the same information.
4848
*/
49-
public static final MediaType ALTERNATIVE = MediaType.get("multipart/alternative");
49+
public static final MediaType ALTERNATIVE = MediaType.parse("multipart/alternative");
5050

5151
/**
5252
* This type is syntactically identical to "multipart/mixed", but the semantics are different. In
5353
* particular, in a digest, the default {@code Content-Type} value for a body part is changed from
5454
* "text/plain" to "message/rfc822".
5555
*/
56-
public static final MediaType DIGEST = MediaType.get("multipart/digest");
56+
public static final MediaType DIGEST = MediaType.parse("multipart/digest");
5757

5858
/**
5959
* This type is syntactically identical to "multipart/mixed", but the semantics are different. In
6060
* particular, in a parallel entity, the order of body parts is not significant.
6161
*/
62-
public static final MediaType PARALLEL = MediaType.get("multipart/parallel");
62+
public static final MediaType PARALLEL = MediaType.parse("multipart/parallel");
6363

6464
/**
6565
* The media-type multipart/form-data follows the rules of all multipart MIME data streams as
6666
* outlined in RFC 2046. In forms, there are a series of fields to be supplied by the user who
6767
* fills out the form. Each field has a name. Within a given form, the names are unique.
6868
*/
69-
public static final MediaType FORM = MediaType.get("multipart/form-data");
69+
public static final MediaType FORM = MediaType.parse("multipart/form-data");
7070

7171
private static final byte[] COLONSPACE = {':', ' '};
7272
private static final byte[] CRLF = {'\r', '\n'};
@@ -81,7 +81,7 @@ public final class MultipartBody extends RequestBody {
8181
MultipartBody(ByteString boundary, MediaType type, List<Part> parts) {
8282
this.boundary = boundary;
8383
this.originalType = type;
84-
this.contentType = MediaType.get(type + "; boundary=" + boundary.utf8());
84+
this.contentType = MediaType.parse(type + "; boundary=" + boundary.utf8());
8585
this.parts = Util.immutableList(parts);
8686
}
8787

0 commit comments

Comments
 (0)