Just for the record, I think that it is not correct to say that the Date header only makes sense for Cache-Control. There might be other uses for it; for example I have seen clients set the local date from there when ntp was not available. There could be other uses too; there is no way to know what people is using it for since it is mandated by RFC2616 and thus can be assumed to be always there.
Guillermo El dom., 9 ago. 2020 a las 0:24, Sergey Ponomarev (<[email protected]>) escribió: > > In RFC 2616 sec. 14.18 said that sever MUST send Date header. > But in fact the header have sense only for Cache-Control and can be omitted. > In the same time the Date eats power, CPU and network resources which are > critical for embedded systems. > > Signed-off-by: Sergey Ponomarev <[email protected]> > --- > networking/httpd.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/networking/httpd.c b/networking/httpd.c > index 9141442c8..7a429d2b5 100644 > --- a/networking/httpd.c > +++ b/networking/httpd.c > @@ -214,6 +214,14 @@ > //config: help > //config: Makes httpd send files using GZIP content encoding if the > //config: client supports it and a pre-compressed <file>.gz exists. > +//config: > +//config:config FEATURE_HTTPD_DATE > +//config: bool "Add Date header to response" > +//config: default y > +//config: depends on HTTPD > +//config: help > +//config: RFC2616 says that sever MUST add Date header to response. > +//config: But it is almost useless and can be omitted. > > //applet:IF_HTTPD(APPLET(httpd, BB_DIR_USR_SBIN, BB_SUID_DROP)) > > @@ -1071,16 +1079,18 @@ static void send_headers(unsigned responseNum) > * always fit into those kbytes. > */ > > - strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, > &tm)); > - /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ > len = sprintf(iobuf, > "HTTP/1.1 %u %s\r\n" > - "Date: %s\r\n" > "Connection: close\r\n", > - responseNum, responseString, > - date_str > + responseNum, responseString > ); > > +#if ENABLE_FEATURE_HTTPD_DATE > + strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, > &tm)); > + /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ > + len += sprintf(iobuf + len, "Date: %s\r\n", date_str); > +#endif > + > if (responseNum != HTTP_OK || found_mime_type) { > len += sprintf(iobuf + len, > "Content-type: %s\r\n", > -- > 2.25.1 > > _______________________________________________ > busybox mailing list > [email protected] > http://lists.busybox.net/mailman/listinfo/busybox -- Guillermo Rodriguez Garcia [email protected] _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
