Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
chenpeng_fei
spring-framework
提交
11b4e3be
S
spring-framework
项目概览
chenpeng_fei
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
11b4e3be
编写于
9月 24, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent HttpMethod resolution against underlying HttpServletRequest
上级
90409cbe
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
16 deletion
+14
-16
spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
...pringframework/web/context/request/ServletWebRequest.java
+1
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java
...vlet/mvc/method/annotation/HttpEntityMethodProcessor.java
+6
-7
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java
.../method/annotation/RequestMappingHandlerAdapterTests.java
+1
-1
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java
...ethod/annotation/ResponseEntityExceptionHandlerTests.java
+5
-5
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java
...method/annotation/ServletInvocableHandlerMethodTests.java
+1
-2
未找到文件。
spring-web/src/main/java/org/springframework/web/context/request/ServletWebRequest.java
浏览文件 @
11b4e3be
...
...
@@ -106,7 +106,7 @@ public class ServletWebRequest extends ServletRequestAttributes implements Nativ
* @since 4.0.2
*/
public
HttpMethod
getHttpMethod
()
{
return
HttpMethod
.
valueOf
(
getRequest
().
getMethod
()
.
trim
().
toUpperCase
()
);
return
HttpMethod
.
valueOf
(
getRequest
().
getMethod
());
}
@Override
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/HttpEntityMethodProcessor.java
浏览文件 @
11b4e3be
...
...
@@ -57,7 +57,6 @@ import org.springframework.web.method.support.ModelAndViewContainer;
*/
public
class
HttpEntityMethodProcessor
extends
AbstractMessageConverterMethodProcessor
{
/**
* Basic constructor with converters only. Suitable for resolving
* {@code HttpEntity}. For handling {@code ResponseEntity} consider also
...
...
@@ -169,11 +168,12 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
if
(!
entityHeaders
.
isEmpty
())
{
outputMessage
.
getHeaders
().
putAll
(
entityHeaders
);
}
Object
body
=
responseEntity
.
getBody
();
if
(
responseEntity
instanceof
ResponseEntity
)
{
outputMessage
.
setStatusCode
(((
ResponseEntity
<?>)
responseEntity
).
getStatusCode
());
if
(
"GET"
.
equals
(
inputMessage
.
getServletRequest
().
getMethod
())
&&
isResourceNotModified
(
inputMessage
,
outputMessage
))
{
if
(
inputMessage
.
getMethod
()
==
HttpMethod
.
GET
&&
isResourceNotModified
(
inputMessage
,
outputMessage
))
{
outputMessage
.
setStatusCode
(
HttpStatus
.
NOT_MODIFIED
);
// Ensure headers are flushed, no body should be written.
outputMessage
.
flush
();
...
...
@@ -190,7 +190,6 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
}
private
boolean
isResourceNotModified
(
ServletServerHttpRequest
inputMessage
,
ServletServerHttpResponse
outputMessage
)
{
List
<
String
>
ifNoneMatch
=
inputMessage
.
getHeaders
().
getIfNoneMatch
();
long
ifModifiedSince
=
inputMessage
.
getHeaders
().
getIfModifiedSince
();
String
eTag
=
addEtagPadding
(
outputMessage
.
getHeaders
().
getETag
());
...
...
@@ -212,10 +211,10 @@ public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodPro
private
boolean
isETagNotModified
(
List
<
String
>
ifNoneMatch
,
String
etag
)
{
if
(
StringUtils
.
hasLength
(
etag
))
{
for
(
String
clientETag
:
ifNoneMatch
)
{
//
c
ompare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3
//
C
ompare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3
if
(
StringUtils
.
hasLength
(
clientETag
)
&&
(
clientETag
.
replaceFirst
(
"^W/"
,
""
).
equals
(
etag
.
replaceFirst
(
"^W/"
,
""
))
||
clientETag
.
equals
(
"*"
)))
{
(
clientETag
.
replaceFirst
(
"^W/"
,
""
).
equals
(
etag
.
replaceFirst
(
"^W/"
,
""
))
||
clientETag
.
equals
(
"*"
)))
{
return
true
;
}
}
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapterTests.java
浏览文件 @
11b4e3be
...
...
@@ -96,7 +96,7 @@ public class RequestMappingHandlerAdapterTests {
this
.
webAppContext
=
new
StaticWebApplicationContext
();
this
.
handlerAdapter
=
new
RequestMappingHandlerAdapter
();
this
.
handlerAdapter
.
setApplicationContext
(
this
.
webAppContext
);
this
.
request
=
new
MockHttpServletRequest
();
this
.
request
=
new
MockHttpServletRequest
(
"GET"
,
"/"
);
this
.
response
=
new
MockHttpServletResponse
();
}
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandlerTests.java
浏览文件 @
11b4e3be
/*
* Copyright 2002-201
3
the original author or authors.
* Copyright 2002-201
5
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -13,16 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.mvc.method.annotation
;
import
java.lang.reflect.Method
;
import
java.util.Arrays
;
import
java.util.EnumSet
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.springframework.beans.ConversionNotSupportedException
;
import
org.springframework.beans.TypeMismatchException
;
...
...
@@ -56,7 +57,6 @@ import org.springframework.web.servlet.mvc.multiaction.NoSuchRequestHandlingMeth
import
org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver
;
import
static
org
.
junit
.
Assert
.*;
import
org.mockito.Mockito
;
/**
* Test fixture for {@link ResponseEntityExceptionHandler}.
...
...
@@ -71,14 +71,14 @@ public class ResponseEntityExceptionHandlerTests {
private
WebRequest
request
;
private
HttpServletRequest
servletRequest
;
private
Mock
HttpServletRequest
servletRequest
;
private
MockHttpServletResponse
servletResponse
;
@Before
public
void
setup
()
{
this
.
servletRequest
=
new
MockHttpServletRequest
();
this
.
servletRequest
=
new
MockHttpServletRequest
(
"GET"
,
"/"
);
this
.
servletResponse
=
new
MockHttpServletResponse
();
this
.
request
=
new
ServletWebRequest
(
this
.
servletRequest
,
this
.
servletResponse
);
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethodTests.java
浏览文件 @
11b4e3be
...
...
@@ -22,7 +22,6 @@ import java.lang.reflect.Method;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.junit.Test
;
...
...
@@ -66,7 +65,7 @@ public class ServletInvocableHandlerMethodTests {
private
final
ModelAndViewContainer
mavContainer
=
new
ModelAndViewContainer
();
private
final
MockHttpServletRequest
request
=
new
MockHttpServletRequest
();
private
final
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"GET"
,
"/"
);
private
final
MockHttpServletResponse
response
=
new
MockHttpServletResponse
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录