Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where the date in response header be set?

I want to know at where the date in response is be set. Considering the date is not the standard property of SeverletResponse.

And our server are nginx+tomcat, and inside the tomcat, it is the spring framework.

I look into the org.apache.catalina.core.ApplicationHttpResponse which implements javax.servlet.http.HttpServletResponse, but cannot find the result. there are some sort of setXXX() methods, even setDateHeader(), by which spring can set "Expires" value.

And maybe the date is be set at nginx layer?

like image 221
avidya Avatar asked Oct 10 '14 03:10

avidya


People also ask

What is the date header in a response?

The Date property represents the value of a Date HTTP header on an HTTP response. The Date header is the date and time the message was sent.

What is the date in the HTTP header?

The Date general HTTP header contains the date and time at which the message originated.

Can we set response header?

You can set response headers, you can add response headers. And you can wonder what the difference is. But think about it for a second, then do this exercise. Draw a line from the HttpResponse method to the method's behavior.


1 Answers

I had a same questions like you, and found it.

See org.apache.coyote.http11.Http11Processor.java 1246:1 (org.apache.tomat.embed:tomcat-embed-core:8.5.15)

// Add date header unless application has already set one (e.g. in a
// Caching Filter)
if (headers.getValue("Date") == null) {
    headers.addValue("Date").setString(FastHttpDateFormat.getCurrentDate());
}
like image 156
NHK Avatar answered Oct 29 '22 10:10

NHK