Java – invalid Jersey expires header
•
Java
I am using Jersey bundle 1.11 to provide some restful web services
Every time I use chrome to browse rest resources, I will notice that HTTP header expires is set to Thu, 01 Jan 1970 01:00:00 CET
I tried to edit the response and add:
return Response.ok( myObject ).expires(new Date(System.currentTimeMillis() + 3000)).build();
Unfortunately, this adds another HTTP header expires instead of replacing the old one
What's the problem?
Solution
Fwiw, I see exactly the same behavior The container here is JBoss 4.2 3. This is a put method using basic authentication My answer is as follows:
Date exp = new Date(System.currentTimeMillis() + lifetime); return Response.noContent().expires(exp).build();
When called with curl, these are the returned headers:
< HTTP/1.1 204 No Content < Server: Apache-Coyote/1.1 < Pragma: No-cache < Cache-Control: no-cache < Expires: Thu,01 Jan 1970 01:00:00 CET < X-Powered-By: Servlet 2.4; JBoss-4.2.3.GA (... < Expires: Tue,13 Mar 2012 11:08:54 GMT < Date: Tue,13 Mar 2012 11:08:24 GMT <
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码