@@ -1717,6 +1717,8 @@ Call<ResponseBody> method(@Part("ping") String ping, @Part("kit") RequestBody ki
1717
1717
assertThat (request .url ().toString ()).isEqualTo ("http://example.com/foo/bar/" );
1718
1718
1719
1719
RequestBody body = request .body ();
1720
+ assertThat (body .contentType ().toString ()).startsWith ("multipart/form-data; boundary=" );
1721
+
1720
1722
Buffer buffer = new Buffer ();
1721
1723
body .writeTo (buffer );
1722
1724
String bodyString = buffer .readUtf8 ();
@@ -2316,7 +2318,9 @@ Call<ResponseBody> method(@Field("foo") String foo, @Field("ping") String ping)
2316
2318
}
2317
2319
}
2318
2320
Request request = buildRequest (Example .class , "bar" , "pong" );
2319
- assertBody (request .body (), "foo=bar&ping=pong" );
2321
+ RequestBody body = request .body ();
2322
+ assertBody (body , "foo=bar&ping=pong" );
2323
+ assertThat (body .contentType ().toString ()).isEqualTo ("application/x-www-form-urlencoded" );
2320
2324
}
2321
2325
2322
2326
@ Test public void formEncodedWithEncodedNameFieldParam () {
@@ -2639,6 +2643,36 @@ Call<ResponseBody> method(@Body RequestBody body) {
2639
2643
assertThat (request .body ().contentType ().toString ()).isEqualTo ("text/not-plain" );
2640
2644
}
2641
2645
2646
+ @ Test public void contentTypeAnnotationHeaderOverridesFormEncoding () {
2647
+ class Example {
2648
+ @ FormUrlEncoded //
2649
+ @ POST ("/foo" ) //
2650
+ @ Headers ("Content-Type: text/not-plain" ) //
2651
+ Call <ResponseBody > method (@ Field ("foo" ) String foo , @ Field ("ping" ) String ping ) {
2652
+ return null ;
2653
+ }
2654
+ }
2655
+ Request request = buildRequest (Example .class , "bar" , "pong" );
2656
+ assertThat (request .body ().contentType ().toString ()).isEqualTo ("text/not-plain" );
2657
+ }
2658
+
2659
+ @ Test public void contentTypeAnnotationHeaderOverridesMultipart () {
2660
+ class Example {
2661
+ @ Multipart //
2662
+ @ POST ("/foo/bar/" ) //
2663
+ @ Headers ("Content-Type: text/not-plain" ) //
2664
+ Call <ResponseBody > method (@ Part ("ping" ) String ping , @ Part ("kit" ) RequestBody kit ) {
2665
+ return null ;
2666
+ }
2667
+ }
2668
+
2669
+ Request request = buildRequest (Example .class , "pong" , RequestBody .create (
2670
+ TEXT_PLAIN , "kat" ));
2671
+
2672
+ RequestBody body = request .body ();
2673
+ assertThat (request .body ().contentType ().toString ()).isEqualTo ("text/not-plain" );
2674
+ }
2675
+
2642
2676
@ Test public void malformedContentTypeHeaderThrows () {
2643
2677
class Example {
2644
2678
@ POST ("/" ) //
0 commit comments