Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
9abd4ed3
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
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,发现更多精彩内容 >>
提交
9abd4ed3
编写于
12月 06, 2018
作者:
L
Lars Grefer
提交者:
Juergen Hoeller
12月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow Instant and ZonedDateTime as Last-Modified header.
Issues: SPR-17571
上级
cf7ee073
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
57 addition
and
0 deletion
+57
-0
spring-web/src/main/java/org/springframework/http/HttpHeaders.java
...b/src/main/java/org/springframework/http/HttpHeaders.java
+25
-0
spring-web/src/main/java/org/springframework/http/ResponseEntity.java
...rc/main/java/org/springframework/http/ResponseEntity.java
+32
-0
未找到文件。
spring-web/src/main/java/org/springframework/http/HttpHeaders.java
浏览文件 @
9abd4ed3
...
...
@@ -1145,6 +1145,22 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
setDate
(
LAST_MODIFIED
,
lastModified
);
}
/**
* Set the time the resource was last changed, as specified by the
* {@code Last-Modified} header.
*/
public
void
setLastModified
(
Instant
lastModified
)
{
setInstant
(
LAST_MODIFIED
,
lastModified
);
}
/**
* Set the time the resource was last changed, as specified by the
* {@code Last-Modified} header.
*/
public
void
setLastModified
(
ZonedDateTime
lastModified
)
{
setZonedDateTime
(
LAST_MODIFIED
,
lastModified
);
}
/**
* Return the time the resource was last changed, as specified by the
* {@code Last-Modified} header.
...
...
@@ -1266,6 +1282,15 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
set
(
headerName
,
DATE_FORMATTERS
[
0
].
format
(
date
));
}
/**
* Set the given date under the given header name after formatting it as a string
* using the RFC-1123 date-time formatter. The equivalent of
* {@link #set(String, String)} but for date headers.
*/
public
void
setInstant
(
String
headerName
,
Instant
date
)
{
setZonedDateTime
(
headerName
,
ZonedDateTime
.
ofInstant
(
date
,
GMT
));
}
/**
* Set the given date under the given header name after formatting it as a string
* using the RFC-1123 date-time formatter. The equivalent of
...
...
spring-web/src/main/java/org/springframework/http/ResponseEntity.java
浏览文件 @
9abd4ed3
...
...
@@ -17,6 +17,8 @@
package
org.springframework.http
;
import
java.net.URI
;
import
java.time.Instant
;
import
java.time.ZonedDateTime
;
import
java.util.Arrays
;
import
java.util.LinkedHashSet
;
import
java.util.Optional
;
...
...
@@ -359,6 +361,24 @@ public class ResponseEntity<T> extends HttpEntity<T> {
*/
B
lastModified
(
long
lastModified
);
/**
* Set the time the resource was last changed, as specified by the
* {@code Last-Modified} header.
* @param lastModified the last modified date
* @return this builder
* @see HttpHeaders#setLastModified(long)
*/
B
lastModified
(
ZonedDateTime
lastModified
);
/**
* Set the time the resource was last changed, as specified by the
* {@code Last-Modified} header.
* @param lastModified the last modified date
* @return this builder
* @see HttpHeaders#setLastModified(long)
*/
B
lastModified
(
Instant
lastModified
);
/**
* Set the location of a resource, as specified by the {@code Location} header.
* @param location the location
...
...
@@ -495,6 +515,18 @@ public class ResponseEntity<T> extends HttpEntity<T> {
return
this
;
}
@Override
public
BodyBuilder
lastModified
(
ZonedDateTime
date
)
{
this
.
headers
.
setLastModified
(
date
);
return
this
;
}
@Override
public
BodyBuilder
lastModified
(
Instant
date
)
{
this
.
headers
.
setLastModified
(
date
);
return
this
;
}
@Override
public
BodyBuilder
location
(
URI
location
)
{
this
.
headers
.
setLocation
(
location
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录