Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created September 14, 2010 14:25
Show Gist options
  • Save sharifulin/579121 to your computer and use it in GitHub Desktop.
Save sharifulin/579121 to your computer and use it in GitHub Desktop.
Is share agent?
sub is_share_agent {
my $self = shift;
my $ua = $self->req->headers->user_agent;
my $range = $self->req->headers->header('Range');
my $enc = $self->req->headers->header('Accept-Encoding');
return
$ua =~ /facebookexternalhit/ && $range && $enc eq 'gzip' ? 'facebook' :
$ua eq 'Mozilla' && !$range && $enc eq 'gzip' ? 'buzz' :
$ua =~ /Mozilla/ && $range && !$enc ? 'vkontakte' :
undef
;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment