From patchwork Mon Jul 2 12:52:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Eckert X-Patchwork-Id: 937879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=dev.tdt.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="o82+582Q"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41K6cX0tVHz9s1B for ; Mon, 2 Jul 2018 22:53:16 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id:Date:To: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=LRUtg5JXeJN8YD4Fjn1PcqncN2njhKvFdjt8c9heMa8=; b=o82+582Q0xsEj3 Ti6I1wFDgHMlbESpPBG/r4bvBfbqVvcd7GB1aUsqjAvCLGENnyUGpHwvRaaknFZTWMqBTXVprZ1zl 5P3Z9oGS3L7QHJ9WhQlE40Yw+if5XZ5WLwmkoKZcpIENpTcsLK4LkJUUAPp7uweDmELzDNMwCyJF2 pK6IpjYQfG7YXmHEHEXoHStOH4tNdpAV8Frf8ZtY9GtvIM1fRKpAWLl0vKPd4tYUj+cqoKrJGR4Yn HSaFJRIWiFGx4jwuw0GoW2Of2+0Dx3K475MPuFChbjGBDFh3Fu5Uu/RycCTTXWPdtSRK0Eh3xLNdR f+pgixzsaea6TZCPLxUw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fZyKF-0008MU-Sn; Mon, 02 Jul 2018 12:53:03 +0000 Received: from ms.tdt.de ([195.243.126.94] helo=mail.dev.tdt.de) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fZyJm-0007xu-C2 for openwrt-devel@lists.openwrt.org; Mon, 02 Jul 2018 12:52:44 +0000 Received: from feckert01.dev.tdt.de (unknown [10.2.3.40]) by mail.dev.tdt.de (Postfix) with ESMTPSA id 2FD2820631 for ; Mon, 2 Jul 2018 12:52:15 +0000 (UTC) From: Florian Eckert To: openwrt-devel@lists.openwrt.org Date: Mon, 2 Jul 2018 14:52:09 +0200 Message-Id: <20180702125210.9749-1-fe@dev.tdt.de> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.dev.tdt.de X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180702_055234_711047_A16BE9DF X-CRM114-Status: GOOD ( 12.09 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- Subject: [OpenWrt-Devel] [PATCH 1/2] services/uhttpd: add -M option for Last-Modified header sending X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org If uhttpd is started with the option -M then Last-Modified header is not send during ok respond. We have already an ETag header set which is more accurate. See URL: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Etag So make sending of Last-Modified header optional with a config option. If the option is not set then the behaviour is as before this option was added. Signed-off-by: Florian Eckert --- ...ct-if-last-modified-header-should-be-send.patch | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 package/network/services/uhttpd/patches/0001-add-a-M-option-to-select-if-last-modified-header-should-be-send.patch diff --git a/package/network/services/uhttpd/patches/0001-add-a-M-option-to-select-if-last-modified-header-should-be-send.patch b/package/network/services/uhttpd/patches/0001-add-a-M-option-to-select-if-last-modified-header-should-be-send.patch new file mode 100644 index 0000000000..9835ca8cfd --- /dev/null +++ b/package/network/services/uhttpd/patches/0001-add-a-M-option-to-select-if-last-modified-header-should-be-send.patch @@ -0,0 +1,46 @@ +--- a/file.c ++++ b/file.c +@@ -337,8 +337,9 @@ static void uh_file_response_ok_hdrs(str + + if (s) { + ustream_printf(cl->us, "ETag: %s\r\n", uh_file_mktag(s, buf, sizeof(buf))); +- ustream_printf(cl->us, "Last-Modified: %s\r\n", +- uh_file_unix2date(s->st_mtime, buf, sizeof(buf))); ++ if(!conf.no_last_modified_header) ++ ustream_printf(cl->us, "Last-Modified: %s\r\n", ++ uh_file_unix2date(s->st_mtime, buf, sizeof(buf))); + } + ustream_printf(cl->us, "Date: %s\r\n", + uh_file_unix2date(time(NULL), buf, sizeof(buf))); +--- a/main.c ++++ b/main.c +@@ -232,7 +232,7 @@ int main(int argc, char **argv) + init_defaults_pre(); + signal(SIGPIPE, SIG_IGN); + +- while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:fh:H:I:i:K:k:L:l:m:N:n:p:qRr:Ss:T:t:U:u:Xx:y:")) != -1) { ++ while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:fh:H:I:i:K:k:L:l:Mm:N:n:p:qRr:Ss:T:t:U:u:Xx:y:")) != -1) { + switch(ch) { + #ifdef HAVE_TLS + case 'C': +@@ -311,6 +311,10 @@ int main(int argc, char **argv) + conf.rfc1918_filter = 1; + break; + ++ case 'M': ++ conf.no_last_modified_header = 1; ++ break; ++ + case 'n': + conf.max_script_requests = atoi(optarg); + break; +--- a/uhttpd.h ++++ b/uhttpd.h +@@ -77,6 +77,7 @@ struct config { + int ubus_noauth; + int ubus_cors; + int cgi_prefix_len; ++ int no_last_modified_header; + struct list_head cgi_alias; + }; +