|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
31 | 31 | import org.springframework.core.MethodParameter;
|
32 | 32 | import org.springframework.core.ResolvableType;
|
33 | 33 | import org.springframework.core.annotation.AliasFor;
|
| 34 | +import org.springframework.http.HttpHeaders; |
34 | 35 | import org.springframework.http.HttpStatus;
|
35 | 36 | import org.springframework.http.ResponseEntity;
|
36 | 37 | import org.springframework.http.converter.HttpMessageConverter;
|
|
46 | 47 | import org.springframework.web.context.request.NativeWebRequest;
|
47 | 48 | import org.springframework.web.context.request.ServletWebRequest;
|
48 | 49 | import org.springframework.web.context.request.async.DeferredResult;
|
| 50 | +import org.springframework.web.filter.ShallowEtagHeaderFilter; |
49 | 51 | import org.springframework.web.method.annotation.RequestParamMethodArgumentResolver;
|
50 | 52 | import org.springframework.web.method.support.HandlerMethodArgumentResolverComposite;
|
51 | 53 | import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
|
@@ -139,6 +141,21 @@ public void invokeAndHandle_VoidRequestNotModified() throws Exception {
|
139 | 141 | this.mavContainer.isRequestHandled());
|
140 | 142 | }
|
141 | 143 |
|
| 144 | + @Test // gh-23775 |
| 145 | + public void invokeAndHandle_VoidNotModifiedWithEtag() throws Exception { |
| 146 | + String etag = "\"deadb33f8badf00d\""; |
| 147 | + this.request.addHeader(HttpHeaders.IF_NONE_MATCH, etag); |
| 148 | + this.webRequest.checkNotModified(etag); |
| 149 | + |
| 150 | + ServletInvocableHandlerMethod handlerMethod = getHandlerMethod(new Handler(), "notModified"); |
| 151 | + handlerMethod.invokeAndHandle(this.webRequest, this.mavContainer); |
| 152 | + |
| 153 | + assertTrue("Null return value + 'not modified' request should result in 'request handled'", |
| 154 | + this.mavContainer.isRequestHandled()); |
| 155 | + |
| 156 | + assertEquals(true, this.request.getAttribute(ShallowEtagHeaderFilter.class.getName() + ".STREAMING")); |
| 157 | + } |
| 158 | + |
142 | 159 | @Test // SPR-9159
|
143 | 160 | public void invokeAndHandle_NotVoidWithResponseStatusAndReason() throws Exception {
|
144 | 161 | ServletInvocableHandlerMethod handlerMethod = getHandlerMethod(new Handler(), "responseStatusWithReason");
|
|
0 commit comments