I don't know if this is a bug, but I urgently need to solve this problem🥹 stackoverflow

Comment From: bclozel

Let's keep this conversation on StackOverflow then. We can reopen this issue if it turns out it's a bug in Spring Boot.

Comment From: SK-XFY

Thank you for your reply. Now I have obtained some new test effects. I send my code to others for testing, they can get the correct results, but I can't get the correct results on my computer I'm even starting to suspect an operating system problem?

从 Windows 版邮件发送

发件人: Brian Clozel 发送时间: 2023年2月16日 17:02 收件人: spring-projects/spring-boot 抄送: SHIKAI; Author 主题: Re: [spring-projects/spring-boot] spring boot upload file over limitERR_CONNECTION_RESET (Issue #34217)

Let's keep this conversation on StackOverflow then. We can reopen this issue if it turns out it's a bug in Spring Boot. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

Comment From: kingron

See full detail: https://mykb.cipindanci.com/archive/SuperKB/4477/ See the diagram why the issue happenned

import org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;
import javax.servlet.http.HttpServletResponse;

@RestControllerAdvice
public class GlobalControllerExceptionHandler {
  @ExceptionHandler(MaxUploadSizeExceededException.class)
  public ResponseEntity<Object> parseSizeLimitExceededException(SizeLimitExceededException exception, HttpServletResponse response) {
    response.setHeader(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, "*");           // <--- 这一行是解决关键
    return logObject("File size exceed limitation: " + exception.getPermittedSize(), exception);
  }
}