Re: [PATCH v5 3/3] gitweb: add If-Modified-Since handling to git_snapshot().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 27, 2012 at 11:31:37PM +0100, Jakub Narebski wrote:
> On Mon, 26 Mar 2012, W. Trevor King wrote:
> > Because snapshots can be large, you can save some bandwidth by
> > supporting caching via If-Modified-Since.  This patch adds support for
> > the i-m-s request to git_snapshot() if the requested hash is a commit.
> 
> "if the requested hash is a commit" means here "if we request snapshot
> of a commit", isn't it?
> 
> > Requests for snapshots of tree-ishes, which lack well defined
> > timestamps, are still handled as they were before.
> 
> s/tree-ishes/trees/.  Commit is tree-ish but not a tree; it is tree
> that lacks timestamp that commit has.

Right.  I'll fix those in v6 ;).

> > +	if (%co) {
> > +		my %latest_date = parse_date($co{'committer_epoch'}, $co{'committer_tz'});
> > +		print $cgi->header(
> > +			-type => $known_snapshot_formats{$format}{'type'},
> > +			-content_disposition => 'inline; filename="' . $filename . '"',
> > +			-last_modified => $latest_date{'rfc2822'},
> > +			-status => '200 OK');
> > +	} else {
> > +		print $cgi->header(
> > +			-type => $known_snapshot_formats{$format}{'type'},
> > +			-content_disposition => 'inline; filename="' . $filename . '"',
> > +			-status => '200 OK');
> > +	}
> 
> This can be written shorter, and with less code repetition using ?: 
> conditional operator:
> 
> > +	print $cgi->header(
> > +		-type => $known_snapshot_formats{$format}{'type'},
> > +		-content_disposition => 'inline; filename="' . $filename . '"',
> > +		 (%co ? -last_modified => $latest_date{'rfc2822'} : ()),
> > +		-status => '200 OK');
> 
> ...or something like that.

Ah, that's much better.  I'm not particulary familar with Perl, sorry ;).

I'll wait until I here back on Last-Modified timestamp generation, and
then submit v6.

-- 
This email may be signed or encrypted with GnuPG (http://www.gnupg.org).
For more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]