Skip to content
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

Maximum Request Size handling support for Undertow in StandardMultipartHttpServletRequest #32549

Closed
ghost opened this issue Mar 28, 2024 · 1 comment
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@ghost
Copy link

ghost commented Mar 28, 2024

Affects: <Spring Framework version> 6.1.5


Dear collegues I was following the discussions in 26096 and 31850 , but not see if we are going to have a support for Request Size (In CommonsMultipartResolver was FileUploadBase.SizeLimitExceededException).

It throws now Caused by: java.lang.IllegalStateException: io.undertow.server.RequestTooBigException: UT000020: Connection terminated as request was larger than 31457280. In case if the similiar check something in message which maybe not best idea can have some similiar check agains words 'request' and 'larger' and throws MaxUploadSizeExceededException as was in CommonsMultipartResolver

	protected void handleParseFailure(Throwable ex) {
		
		Throwable cause = ex;
		do {
			String msg = cause.getMessage();
			if (msg != null) {
				msg = msg.toLowerCase();
                                 // checks against file maximum size
				if (msg.contains("exceed") && (msg.contains("size") || msg.contains("length"))) {
					throw new MaxUploadSizeExceededException(-1, ex);
				}
                                  // checks against request maximum size
                                 if (msg.contains("request") && (msg.contains("larger")) {					
                                         throw new MaxUploadSizeExceededException(-1, ex);
				}
			}
			cause = cause.getCause();
		}
		while (cause != null);

		// General MultipartException
		throw new MultipartException("Failed to parse multipart servlet request", ex);
	}

Thanks in advance

@ghost ghost changed the title Can we have Maximum Request Size handling as well Can we have Maximum Request Size handling support in StandardMultipartHttpServletRequest Mar 28, 2024
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 28, 2024
@jhoeller jhoeller changed the title Can we have Maximum Request Size handling support in StandardMultipartHttpServletRequest Maximum Request Size handling support for Undertow in StandardMultipartHttpServletRequest Mar 28, 2024
@jhoeller jhoeller added in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 28, 2024
@jhoeller jhoeller self-assigned this Mar 28, 2024
@jhoeller jhoeller added this to the 6.1.6 milestone Mar 28, 2024
@ghost
Copy link
Author

ghost commented Apr 5, 2024

Thanks @jhoeller and Spring Team

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants