|
25 | 25 | import java.net.URI; |
26 | 26 | import java.util.Hashtable; |
27 | 27 | import java.util.Map; |
| 28 | +import java.util.concurrent.CompletableFuture; |
28 | 29 | import java.util.concurrent.ExecutionException; |
29 | 30 |
|
30 | 31 | import javax.inject.Inject; |
|
34 | 35 | import jakarta.servlet.http.HttpServletRequest; |
35 | 36 | import jakarta.servlet.http.HttpServletResponse; |
36 | 37 |
|
| 38 | +import org.eclipse.jetty.client.CompletableResponseListener; |
37 | 39 | import org.eclipse.jetty.client.ContentResponse; |
| 40 | +import org.eclipse.jetty.client.FormRequestContent; |
38 | 41 | import org.eclipse.jetty.client.HttpClient; |
| 42 | +import org.eclipse.jetty.client.Request; |
39 | 43 | import org.eclipse.jetty.util.Fields; |
40 | 44 | import org.junit.Before; |
41 | 45 | import org.junit.Test; |
@@ -119,15 +123,12 @@ public void testRequestResponseLimits() throws Exception { |
119 | 123 | Fields formFieldsLimitExceeded = new Fields(); |
120 | 124 | formFieldsLimitExceeded.add(new Fields.Field("key","valueoverlimit")); // over limit of 10 bytes |
121 | 125 |
|
122 | | - try { |
123 | | - ContentResponse responseExceeded = httpClient.FORM(new URI(String.format("http://localhost:%d/withinlimit/a", httpPort)), formFieldsLimitExceeded); |
| 126 | + Request request = httpClient.newRequest(new URI(String.format("http://localhost:%d/withinlimit/a", httpPort))) |
| 127 | + .body(new FormRequestContent(formFieldsLimitExceeded)); |
124 | 128 |
|
125 | | - // Request limit exceeded, HTTP 413 directly from Jetty |
126 | | - assertEquals(413, responseExceeded.getStatus()); |
127 | | - } catch (ExecutionException e) { |
128 | | - // FIXME this shouldn't happen, but it does with Jetty 12.1.0.beta0 |
129 | | - // java.nio.channels.AsynchronousCloseException |
130 | | - } |
| 129 | + CompletableFuture<ContentResponse> completable = new CompletableResponseListener(request).send(); |
| 130 | + ContentResponse response = completable.get(); |
| 131 | + assertEquals(413, response.getStatus()); |
131 | 132 | } |
132 | 133 | } |
133 | 134 |
|
|
0 commit comments