File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation
spring-web/src/main/java/org/springframework/web/bind/annotation Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 195195 * The entity body will be converted to the response stream using
196196 * {@linkplain org.springframework.http.converter.HttpMessageConverter message
197197 * converters}.
198+ * <li>An {@link org.springframework.http.HttpHeaders HttpHeaders} object to
199+ * return a response with no body.</li>
198200 * <li>A {@link Callable} which is used by Spring MVC to obtain the return
199201 * value asynchronously in a separate thread transparently managed by Spring MVC
200202 * on behalf of the application.
Original file line number Diff line number Diff line change @@ -41,17 +41,18 @@ public boolean supportsReturnType(MethodParameter returnType) {
4141
4242 @ Override
4343 public void handleReturnValue (Object returnValue , MethodParameter returnType ,
44- ModelAndViewContainer mavContainer , NativeWebRequest webRequest ) throws Exception {
44+ ModelAndViewContainer mavContainer , NativeWebRequest webRequest ) throws Exception {
45+
4546 mavContainer .setRequestHandled (true );
4647
4748 Assert .isInstanceOf (HttpHeaders .class , returnValue );
4849 HttpHeaders headers = (HttpHeaders ) returnValue ;
4950
50- HttpServletResponse response = webRequest .getNativeResponse (HttpServletResponse .class );
51- ServletServerHttpResponse outputMessage = new ServletServerHttpResponse (response );
5251 if (!headers .isEmpty ()) {
52+ HttpServletResponse servletResponse = webRequest .getNativeResponse (HttpServletResponse .class );
53+ ServletServerHttpResponse outputMessage = new ServletServerHttpResponse (servletResponse );
5354 outputMessage .getHeaders ().putAll (headers );
55+ outputMessage .getBody (); // flush headers
5456 }
55- outputMessage .getBody (); // flush headers
5657 }
5758}
Original file line number Diff line number Diff line change @@ -29033,9 +29033,10 @@ The following are the supported return types:
2903329033* If the method is annotated with `@ResponseBody`, the return type is written to the
2903429034 response HTTP body. The return value will be converted to the declared method argument
2903529035 type using `HttpMessageConverter` s. See <<mvc-ann-responsebody>>.
29036- * A `HttpEntity<?>` or `ResponseEntity<?>` object to provide access to the Servlet
29036+ * An `HttpEntity<?>` or `ResponseEntity<?>` object to provide access to the Servlet
2903729037 response HTTP headers and contents. The entity body will be converted to the response
2903829038 stream using `HttpMessageConverter` s. See <<mvc-ann-httpentity>>.
29039+ * An `HttpHeaders` object to return a response with no body.
2903929040* A `Callable<?>` can be returned when the application wants to produce the return value
2904029041 asynchronously in a thread managed by Spring MVC.
2904129042* A `DeferredResult<?>` can be returned when the application wants to produce the return
You can’t perform that action at this time.
0 commit comments