[libnet-openid-common-perl] 02/07: merge pasted code
gregor herrmann
gregoa at debian.org
Sun Feb 7 21:50:32 UTC 2016
This is an automated email from the git hooks/post-receive script.
gregoa pushed a commit to annotated tag v1.13
in repository libnet-openid-common-perl.
commit 8f33ba28212905d375e9e1627d4e248b47ad258a
Author: Roger Crew <crew at cs.stanford.edu>
Date: Sat Nov 5 12:50:39 2011 -0700
merge pasted code
I hate ^Y progamming
---
lib/Net/OpenID/URIFetch.pm | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/lib/Net/OpenID/URIFetch.pm b/lib/Net/OpenID/URIFetch.pm
index e99eedc..0f171a6 100644
--- a/lib/Net/OpenID/URIFetch.pm
+++ b/lib/Net/OpenID/URIFetch.pm
@@ -65,6 +65,14 @@ sub fetch {
$ref = Storable::thaw($blob);
}
}
+ my $cached_response = sub {
+ return Net::OpenID::URIFetch::Response->new(
+ status => 200,
+ content => $ref->{Content},
+ headers => $ref->{Headers},
+ final_uri => $ref->{FinalURI},
+ );
+ };
# We just serve anything from the last 60 seconds right out of the cache,
# thus avoiding doing several requests to the same URL when we do
@@ -72,12 +80,7 @@ sub fetch {
# TODO: Make this tunable?
if ($ref && $ref->{CacheTime} > (time() - 60)) {
$consumer->_debug("Cache HIT for $uri");
- return Net::OpenID::URIFetch::Response->new(
- status => 200,
- content => $ref->{Content},
- headers => $ref->{Headers},
- final_uri => $ref->{FinalURI},
- );
+ return $cached_response->();
}
else {
$consumer->_debug("Cache MISS for $uri");
@@ -105,12 +108,7 @@ sub fetch {
if ($res->code == HTTP::Status::RC_NOT_MODIFIED()) {
$consumer->_debug("Server says it's not modified. Serving from cache.");
- return Net::OpenID::URIFetch::Response->new(
- status => 200,
- content => $ref->{Content},
- headers => $ref->{Headers},
- final_uri => $ref->{FinalURI},
- );
+ return $cached_response->();
}
else {
my $content = $res->content;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libnet-openid-common-perl.git
More information about the Pkg-perl-cvs-commits
mailing list