sub _new
{ my ($self, @param) = @_;
$self->SUPER::_new(@param);
$self->dsn("http://".$self->host.":".$self->port.$self->path."?"); } |
sub getResultSet
{
my ($self, $qualifier,$type,$xml)=@_;
if (!defined $xml){$xml=""}
my $logger=Log::Log4perl->get_logger(__PACKAGE__);
my $request;
if ($type eq "POST"){
$logger->warn("POST: ", $self->dsn," query=$xml");
$request = HTTP::Request->new($type,$self->dsn,
HTTP::Headers->new(),'query='.$xml."\n");
} elsif ($type eq "GET") {
$qualifier=$qualifier."&requestid=biomart-client";
$logger->warn("GET: ", $self->dsn," $qualifier");
$request = HTTP::Request->new($type,$self->dsn.$qualifier);
} else {
BioMart::Exception::Query->throw("need a valid request type: GET or POST");
}
my $ua = LWP::UserAgent->new;
$ua->timeout(20); $ua->proxy( ['http', 'https'], $self->proxy ) if defined $self->proxy;
my $response = $ua->request($request);
my @results;
if ($response->is_success) {
my @arr=split(/\n/,$response->as_string);
foreach my $el(@arr){
if ($el =~ /^Keep-Alive/) {next;}
if ($el =~ /^Vary/) {next;}
if ($el =~ /^Client/) {next;}
if ($el eq '') {next;}
if ($el =~/^HTTP/) { next;}
if ($el =~/^Date/) { next;}
if ($el =~/^Server/) {next;}
if ($el =~/^Connection/) {next;}
if ($el =~/^Content/) {next;}
if ($el =~/^Proxy/) {next;}
if ($el =~/^X-Cache/) {next;}
if ($el =~/^Via/) {next;}
if ($el =~/^X-Pad/) {next;}
$logger->warn("RESPONSE: $el");
push (@results,$el);
}
} else {
warn ("\n\nProblems with the web server: ".
$response->status_line."\n\n");
}
return @results;
}
1; } |