-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the ability to configure the maximum form attribute size
Vert.x defaults to 2K and prior to this PR we didn't have a way to configure it. Fixes: #16422
- Loading branch information
Showing
4 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
.../java/io/quarkus/resteasy/reactive/server/test/multipart/LargeMultipartFormInputTest.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,89 @@ | ||
package io.quarkus.resteasy.reactive.server.test.multipart; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.util.function.Supplier; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.FormParam; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.jboss.resteasy.reactive.MultipartForm; | ||
import org.jboss.resteasy.reactive.PartType; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
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.restassured.http.ContentType; | ||
import io.vertx.core.http.HttpServerOptions; | ||
|
||
public class LargeMultipartFormInputTest { | ||
|
||
@RegisterExtension | ||
static QuarkusUnitTest test = new QuarkusUnitTest() | ||
.setArchiveProducer(new Supplier<JavaArchive>() { | ||
@Override | ||
public JavaArchive get() { | ||
return ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(Resource.class, Data.class) | ||
.addAsResource(new StringAsset( | ||
"quarkus.http.limits.max-form-attribute-size=4K"), | ||
"application.properties"); | ||
} | ||
}); | ||
|
||
private static final File FILE = new File("./src/test/resources/larger-than-default-form-attribute.txt"); | ||
|
||
@Test | ||
public void test() throws IOException { | ||
String fileContents = new String(Files.readAllBytes(FILE.toPath()), StandardCharsets.UTF_8); | ||
Assertions.assertTrue(fileContents.length() > HttpServerOptions.DEFAULT_MAX_FORM_ATTRIBUTE_SIZE); | ||
given() | ||
.multiPart("text", fileContents) | ||
.accept("text/plain") | ||
.when() | ||
.post("/test") | ||
.then() | ||
.statusCode(200) | ||
.contentType(ContentType.TEXT) | ||
.body(equalTo(fileContents)); | ||
} | ||
|
||
@Path("/test") | ||
public static class Resource { | ||
|
||
@POST | ||
@Consumes(MediaType.MULTIPART_FORM_DATA) | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello(@MultipartForm Data data) { | ||
return data.getText(); | ||
} | ||
} | ||
|
||
public static class Data { | ||
@FormParam("text") | ||
@PartType("text/plain") | ||
private String text; | ||
|
||
public String getText() { | ||
return text; | ||
} | ||
|
||
public void setText(String text) { | ||
this.text = text; | ||
} | ||
} | ||
|
||
} |
143 changes: 143 additions & 0 deletions
143
...us-resteasy-reactive/deployment/src/test/resources/larger-than-default-form-attribute.txt
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,143 @@ | ||
File-Date: 2018-04-23 | ||
%% | ||
Type: language | ||
Subtag: aa | ||
Description: Afar | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: ab | ||
Description: Abkhazian | ||
Added: 2005-10-16 | ||
Suppress-Script: Cyrl | ||
%% | ||
Type: language | ||
Subtag: ae | ||
Description: Avestan | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: af | ||
Description: Afrikaans | ||
Added: 2005-10-16 | ||
Suppress-Script: Latn | ||
%% | ||
Type: language | ||
Subtag: ak | ||
Description: Akan | ||
Added: 2005-10-16 | ||
Scope: macrolanguage | ||
%% | ||
Type: language | ||
Subtag: am | ||
Description: Amharic | ||
Added: 2005-10-16 | ||
Suppress-Script: Ethi | ||
%% | ||
Type: language | ||
Subtag: an | ||
Description: Aragonese | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: ar | ||
Description: Arabic | ||
Added: 2005-10-16 | ||
Suppress-Script: Arab | ||
Scope: macrolanguage | ||
%% | ||
Type: language | ||
Subtag: as | ||
Description: Assamese | ||
Added: 2005-10-16 | ||
Suppress-Script: Beng | ||
%% | ||
Type: language | ||
Subtag: av | ||
Description: Avaric | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: ay | ||
Description: Aymara | ||
Added: 2005-10-16 | ||
Suppress-Script: Latn | ||
Scope: macrolanguage | ||
%% | ||
Type: language | ||
Subtag: az | ||
Description: Azerbaijani | ||
Added: 2005-10-16 | ||
Scope: macrolanguage | ||
%% | ||
Type: language | ||
Subtag: ba | ||
Description: Bashkir | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: be | ||
Description: Belarusian | ||
Added: 2005-10-16 | ||
Suppress-Script: Cyrl | ||
%% | ||
Type: language | ||
Subtag: bg | ||
Description: Bulgarian | ||
Added: 2005-10-16 | ||
Suppress-Script: Cyrl | ||
%% | ||
Type: language | ||
Subtag: bh | ||
Description: Bihari languages | ||
Added: 2005-10-16 | ||
Scope: collection | ||
%% | ||
Type: language | ||
Subtag: bi | ||
Description: Bislama | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: bm | ||
Description: Bambara | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: bn | ||
Description: Bengali | ||
Description: Bangla | ||
Added: 2005-10-16 | ||
Suppress-Script: Beng | ||
%% | ||
Type: language | ||
Subtag: bo | ||
Description: Tibetan | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: br | ||
Description: Breton | ||
Added: 2005-10-16 | ||
%% | ||
Type: language | ||
Subtag: bs | ||
Description: Bosnian | ||
Added: 2005-10-16 | ||
Suppress-Script: Latn | ||
Macrolanguage: sh | ||
%% | ||
Type: language | ||
Subtag: ca | ||
Description: Catalan | ||
Description: Valencian | ||
Added: 2005-10-16 | ||
Suppress-Script: Latn | ||
%% | ||
Type: language | ||
Subtag: ce | ||
Description: | ||
%% | ||
Type: language | ||
Subtag: ce | ||
Description: |
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