|
28 | 28 | import feign.assertj.MockWebServerAssertions;
|
29 | 29 | import okhttp3.mockwebserver.MockResponse;
|
30 | 30 | import okhttp3.mockwebserver.SocketPolicy;
|
| 31 | +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
31 | 32 |
|
32 | 33 | /**
|
33 | 34 | * Tests client-specific behavior, such as ensuring Content-Length is sent when specified.
|
@@ -79,17 +80,37 @@ public void patch() throws Exception {
|
79 | 80 | assertThat(exception).hasCauseInstanceOf(ProtocolException.class);
|
80 | 81 | }
|
81 | 82 |
|
| 83 | + @Test |
82 | 84 | @Override
|
83 | 85 | public void noResponseBodyForPost() throws Exception {
|
84 | 86 | super.noResponseBodyForPost();
|
85 | 87 | MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST")
|
| 88 | + .hasNoHeaderNamed("Content-Type"); |
| 89 | + } |
| 90 | + |
| 91 | + @Test |
| 92 | + @EnabledIfSystemProperty(named = "sun.net.http.allowRestrictedHeaders", matches = "true") |
| 93 | + public void noRequestBodyForPostWithAllowRestrictedHeaders() throws Exception { |
| 94 | + super.noResponseBodyForPost(); |
| 95 | + MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("POST") |
| 96 | + .hasNoHeaderNamed("Content-Type") |
86 | 97 | .hasHeaders(entry("Content-Length", Collections.singletonList("0")));
|
87 | 98 | }
|
88 | 99 |
|
| 100 | + @Test |
89 | 101 | @Override
|
90 | 102 | public void noResponseBodyForPut() throws Exception {
|
91 | 103 | super.noResponseBodyForPut();
|
92 | 104 | MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("PUT")
|
| 105 | + .hasNoHeaderNamed("Content-Type"); |
| 106 | + } |
| 107 | + |
| 108 | + @Test |
| 109 | + @EnabledIfSystemProperty(named = "sun.net.http.allowRestrictedHeaders", matches = "true") |
| 110 | + public void noResponseBodyForPutWithAllowRestrictedHeaders() throws Exception { |
| 111 | + super.noResponseBodyForPut(); |
| 112 | + MockWebServerAssertions.assertThat(server.takeRequest()).hasMethod("PUT") |
| 113 | + .hasNoHeaderNamed("Content-Type") |
93 | 114 | .hasHeaders(entry("Content-Length", Collections.singletonList("0")));
|
94 | 115 | }
|
95 | 116 |
|
|
0 commit comments