-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade to Vert.x 4.4.9 with backports #39788
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
175 changes: 175 additions & 0 deletions
175
extensions/vertx-http/deployment/src/test/java/io/quarkus/vertx/http/form/FormTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
package io.quarkus.vertx.http.form; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicReference; | ||
|
||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.enterprise.event.Observes; | ||
import jakarta.inject.Inject; | ||
|
||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.vertx.core.Vertx; | ||
import io.vertx.core.http.HttpClient; | ||
import io.vertx.core.http.HttpClientResponse; | ||
import io.vertx.core.http.HttpMethod; | ||
import io.vertx.core.http.RequestOptions; | ||
import io.vertx.ext.web.Router; | ||
import io.vertx.ext.web.handler.BodyHandler; | ||
|
||
public class FormTest { | ||
|
||
private static final String APP_PROPS = "quarkus.http.limits.max-form-fields=10\n" + | ||
"quarkus.http.limits.max-form-buffered-bytes=100\n"; | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addAsResource(new StringAsset(APP_PROPS), "application.properties") | ||
.addClasses(BeanRegisteringRouteUsingObserves.class)); | ||
|
||
@Inject | ||
Vertx vertx; | ||
|
||
@Test | ||
public void testTooManyFields() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
AtomicReference<HttpClientResponse> reference = new AtomicReference<>(); | ||
HttpClient client = vertx.createHttpClient(); | ||
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form")) | ||
.onComplete(ar -> { | ||
var req = ar.result(); | ||
req.setChunked(true); | ||
req.putHeader("content-type", "application/x-www-form-urlencoded"); | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < 20; i++) { | ||
if (i > 0) { | ||
sb.append('&'); | ||
} | ||
sb.append("a").append(i).append("=").append("b"); | ||
} | ||
req.write(sb.toString()); | ||
vertx.setTimer(10, id -> { | ||
req.end(); | ||
}); | ||
|
||
req.response().onComplete(rc -> { | ||
reference.set(rc.result()); | ||
latch.countDown(); | ||
}); | ||
}); | ||
latch.await(10, TimeUnit.SECONDS); | ||
Assertions.assertEquals(400, reference.get().statusCode()); | ||
} | ||
|
||
@Test | ||
public void testOkForm() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
AtomicReference<HttpClientResponse> reference = new AtomicReference<>(); | ||
HttpClient client = vertx.createHttpClient(); | ||
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form")) | ||
.onComplete(ar -> { | ||
var req = ar.result(); | ||
req.setChunked(true); | ||
req.putHeader("content-type", "application/x-www-form-urlencoded"); | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < 10; i++) { | ||
if (i > 0) { | ||
sb.append('&'); | ||
} | ||
sb.append("a").append(i).append("=").append("b"); | ||
} | ||
req.write(sb.toString()); | ||
vertx.setTimer(10, id -> { | ||
req.end(); | ||
}); | ||
|
||
req.response().onComplete(rc -> { | ||
reference.set(rc.result()); | ||
latch.countDown(); | ||
}); | ||
}); | ||
latch.await(10, TimeUnit.SECONDS); | ||
Assertions.assertEquals(200, reference.get().statusCode()); | ||
} | ||
|
||
@Test | ||
public void testTooManyBytes() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
AtomicReference<HttpClientResponse> reference = new AtomicReference<>(); | ||
HttpClient client = vertx.createHttpClient(); | ||
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form")) | ||
.onComplete(ar -> { | ||
var req = ar.result(); | ||
req.setChunked(true); | ||
req.putHeader("content-type", "application/x-www-form-urlencoded"); | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < 200; i++) { | ||
sb.append("a"); | ||
} | ||
req.write(sb.toString()); | ||
vertx.setTimer(10, id -> { | ||
req.end("=b"); | ||
}); | ||
|
||
req.response().onComplete(rc -> { | ||
reference.set(rc.result()); | ||
latch.countDown(); | ||
}); | ||
}); | ||
latch.await(10, TimeUnit.SECONDS); | ||
Assertions.assertEquals(400, reference.get().statusCode()); | ||
} | ||
|
||
@Test | ||
public void testBytesOk() throws Exception { | ||
CountDownLatch latch = new CountDownLatch(1); | ||
AtomicReference<HttpClientResponse> reference = new AtomicReference<>(); | ||
HttpClient client = vertx.createHttpClient(); | ||
client.request(new RequestOptions().setMethod(HttpMethod.POST).setAbsoluteURI("http://localhost:8081/form")) | ||
.onComplete(ar -> { | ||
var req = ar.result(); | ||
req.setChunked(true); | ||
req.putHeader("content-type", "application/x-www-form-urlencoded"); | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < 100; i++) { | ||
sb.append("a"); | ||
} | ||
req.write(sb.toString()); | ||
vertx.setTimer(10, id -> { | ||
req.end("=b"); | ||
}); | ||
|
||
req.response().onComplete(rc -> { | ||
reference.set(rc.result()); | ||
latch.countDown(); | ||
}); | ||
}); | ||
latch.await(10, TimeUnit.SECONDS); | ||
Assertions.assertEquals(200, reference.get().statusCode()); | ||
} | ||
|
||
@ApplicationScoped | ||
static class BeanRegisteringRouteUsingObserves { | ||
|
||
public void register(@Observes Router router) { | ||
|
||
router | ||
.post().order(Integer.MIN_VALUE).handler(rc -> { | ||
rc.request().setExpectMultipart(true); | ||
rc.next(); | ||
}); | ||
router.post().handler(BodyHandler.create()); | ||
router.post("/form") | ||
.handler(rc -> { | ||
rc.response().end("OK"); | ||
}); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jponge this config parameter doesn't seem to be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, it might be removed