1515import feign .Param ;
1616import feign .RequestLine ;
1717import feign .Response ;
18+ import feign .Util ;
1819import feign .assertj .MockWebServerAssertions ;
1920import okhttp3 .mockwebserver .MockResponse ;
2021import okhttp3 .mockwebserver .MockWebServer ;
@@ -218,6 +219,30 @@ public void testResponseLength() throws Exception {
218219 assertEquals (expected , actual );
219220 }
220221
222+ @ Test
223+ public void testContentTypeWithCharset () throws Exception {
224+ server .enqueue (new MockResponse ()
225+ .setBody ("AAAAAAAA" ));
226+ TestInterface api = newBuilder ()
227+ .target (TestInterface .class , "http://localhost:" + server .getPort ());
228+
229+ Response response = api .postWithContentType ("foo" , "text/plain;charset=utf-8" );
230+ // Response length should not be null
231+ assertEquals ("AAAAAAAA" , Util .toString (response .body ().asReader ()));
232+ }
233+
234+ @ Test
235+ public void testContentTypeWithoutCharset () throws Exception {
236+ server .enqueue (new MockResponse ()
237+ .setBody ("AAAAAAAA" ));
238+ TestInterface api = newBuilder ()
239+ .target (TestInterface .class , "http://localhost:" + server .getPort ());
240+
241+ Response response = api .postWithContentType ("foo" , "text/plain" );
242+ // Response length should not be null
243+ assertEquals ("AAAAAAAA" , Util .toString (response .body ().asReader ()));
244+ }
245+
221246 public interface TestInterface {
222247
223248 @ RequestLine ("POST /?foo=bar&foo=baz&qux=" )
@@ -241,6 +266,10 @@ public interface TestInterface {
241266
242267 @ RequestLine ("PUT" )
243268 String noPutBody ();
269+
270+ @ RequestLine ("POST /?foo=bar&foo=baz&qux=" )
271+ @ Headers ({"Foo: Bar" , "Foo: Baz" , "Qux: " , "Content-Type: {contentType}" })
272+ Response postWithContentType (String body , @ Param ("contentType" ) String contentType );
244273 }
245274
246275}
0 commit comments