简体   繁体   中英

RFC 1123 date representation with Jetty

We're using jetty as front end http server, with cache policies. I would like to be clear on the requirements:

  1. Is the quoted below required?
  2. How should I implement this in Java?

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html says:

HTTP/1.1 requires origin servers to send a Date header, if possible, with every response, giving the time at which the response was generated (see section 14.18). We use the term "date_value" to denote the value of the Date header, in a form appropriate for arithmetic operations.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18 :

The Date general-header field represents the date and time at which the message was originated, having the same semantics as orig-date in RFC 822. The field value is an HTTP-date, as described in section 3.3.1; it MUST be sent in RFC 1123 [8]-date format.

Does jetty contains built in support for Date fields or should I be adding this by myself? Any efficient method to generate this field?

Thank you,
Maxim.

The org.eclipse.jetty.server.Server class has a boolean sendDateHeader property that enables this. It really should be done by default, but it isn't.

You can either set that programmatically, or usins a <Set> element in jetty.xml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM