user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 3/6] githttpbackend: remove unused $BIN variable
  @ 2022-10-20  8:43  4% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2022-10-20  8:43 UTC (permalink / raw)
  To: meta

It hasn't been used in many years since commit
c1630b7dc4ef (githttpbackend: match Content-Type of git-http-backend(1), 2016-07-03)
---
 lib/PublicInbox/GitHTTPBackend.pm | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index 72b8e6c3..1eb51f27 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -27,7 +27,6 @@ my @binary = ('objects/[a-f0-9]{2}/[a-f0-9]{38,62}',
 	'objects/pack/pack-[a-f0-9]{40,64}\.(?:pack|idx)');
 
 our $ANY = join('|', @binary, @text, 'git-upload-pack');
-my $BIN = join('|', @binary);
 my $TEXT = join('|', @text);
 
 sub serve {

^ permalink raw reply related	[relevance 4%]

* [PATCH] githttpbackend: match Content-Type of git-http-backend(1)
@ 2016-07-03  0:43  7% Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2016-07-03  0:43 UTC (permalink / raw)
  To: meta

This will allow cache proxies such as Varnish to avoid
caching data sent by us.
---
 lib/PublicInbox/GitHTTPBackend.pm | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index b485192..a9c0e9c 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -64,15 +64,29 @@ sub drop_client ($) {
 	}
 }
 
+my $prev = 0;
+my $exp;
+sub cache_one_year {
+	my ($h) = @_;
+	my $t = time + 31536000;
+	push @$h, 'Expires', $t == $prev ? $exp : ($exp = time2str($prev = $t)),
+		'Cache-Control', 'public, max-age=31536000';
+}
+
 sub serve_dumb {
 	my ($env, $git, $path) = @_;
 
 	my @h;
 	my $type;
-	if ($path =~ /\A(?:$BIN)\z/o) {
-		$type = 'application/octet-stream';
-		push @h, 'Expires', time2str(time + 31536000);
-		push @h, 'Cache-Control', 'public, max-age=31536000';
+	if ($path =~ m!\Aobjects/[a-f0-9]{2}/[a-f0-9]{38}\z!) {
+		$type = 'application/x-git-loose-object';
+		cache_one_year(\@h);
+	} elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40}\.pack\z!) {
+		$type = 'application/x-git-packed-objects';
+		cache_one_year(\@h);
+	} elsif ($path =~ m!\Aobjects/pack/pack-[a-f0-9]{40}\.idx\z!) {
+		$type = 'application/x-git-packed-objects-toc';
+		cache_one_year(\@h);
 	} elsif ($path =~ /\A(?:$TEXT)\z/o) {
 		$type = 'text/plain';
 		push @h, @no_cache;
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-07-03  0:43  7% [PATCH] githttpbackend: match Content-Type of git-http-backend(1) Eric Wong
2022-10-20  8:43     [PATCH 0/6] trivial clone|fetch-related stuff Eric Wong
2022-10-20  8:43  4% ` [PATCH 3/6] githttpbackend: remove unused $BIN variable Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).