Set last modified out header

Maxim Dounin mdounin at mdounin.ru
Wed Feb 10 13:15:43 UTC 2016


Hello!

On Wed, Feb 10, 2016 at 03:44:13AM -0500, Ortal wrote:

> Hello,
> I am building my own NGINX module, when I try to set the last modified out
> header I have a struct timespec which I need to convert to last modified.
> When I set the last modified with the tv_sec the last modified get invalid
> date. 
> 
> How can I set the last modified correctly?

The "struct timespec" is not guaranteed to contain time since any 
specific point in the past.  So the question is: how did you got 
the struct timespec?

E.g., when using clock_gettime(CLOCK_REALTIME), tv_sec is expected 
to contain seconds since the Epoch, and it should work fine.  But 
when using clock_gettime(CLOCK_MONOTONIC) tv_sec is "since an 
unspecified point in the past" (quoting POSIX, see [1]), and it's 
not possible to convert it to time since the Epoch as required by 
r->headers_out.last_modified_time.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx mailing list