This file is indexed.

/usr/share/perl5/Finance/Quote/UserAgent.pm is in libfinance-quote-perl 1.38-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
#!/usr/bin/perl -w
#
#	Copyright (C) 2000, Paul Fenwick <pjf@cpan.org>
#
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; either version 2 of the License, or
#	(at your option) any later version.
#
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, write to the Free Software
#	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#	02111-1307, USA
#
# This module defines our own LWP::UserAgent, in particular it allows
# user-defined headers to be set which will be automatically added to
# new HTTP requests.  This is particularly important if you wish to get
# through authenticated proxies and the like.

package Finance::Quote::UserAgent;
require 5.005;

use strict;
use LWP::UserAgent;
use HTTP::Headers;

use vars qw/@ISA /;

our $VERSION = '1.38'; # VERSION
@ISA = qw/LWP::UserAgent/;

# A very simple extension.  When we generate a LWP::UserAgent object,
# we add an extra field called finance_quote_headers which stores an
# HTTP::Headers object.

sub new {
	my $ua = LWP::UserAgent::new(@_);
	$ua->{finance_quote_headers} = HTTP::Headers->new();
	return $ua;
}

# This returns the HTTP::Headers object, so the user can play with it.
sub default_headers {
	my $this = shift;
	return $this->{finance_quote_headers};
}

# Over-ride for the simple_request method.  This sets the user-supplied
# template headers if they have not already been set in the request.
sub simple_request {
	my ($this, $request, @args) = @_;
	my $new_request = $this->_add_custom_headers($request);
	return $this->SUPER::simple_request($new_request,@args);
}

# Over-ride for the request method.  This also sets the user-supplied
# template headers if they have not already been set in the request.
sub request {
	my ($this, $request, @args) = @_;
	my $new_request = $this->_add_custom_headers($request);
	return $this->SUPER::request($new_request,@args);
}

# _add_custom_headers is a private method which does the dirty work
# of copying across headers and other fun things.
#
# We take the user-defined template, and then overlay the request over the
# top of it.  This should get us by in most situations.

sub _add_custom_headers {
	my ($this, $request) = @_;
	my $header_template = $this->default_headers;
	my $new_request = $request->clone; # Modifying the original is rude.

	# Copy things that are in the template that we don't have
	# defined in the request.

	$header_template->scan(sub {
		$new_request->header($_[0],$_[1]) unless
			defined ($new_request->header($_[0]));
	});

	return $new_request;
}

# If users wish to place their username and proxy password(!) into
# the "http_proxy_auth_clear" environment variable, then we'll
# read it out and automatically use it for proxy requests.

sub env_proxy {
	my ($this, @args) = @_;
	if ($ENV{http_proxy_auth_clear}) {
		$this->default_headers->proxy_authorization_basic(
			split(/:/,$ENV{http_proxy_auth_clear}));
	}
	$this->SUPER::env_proxy(@_);
}

1;