LICENSE

Copyright [1999-2015] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute Copyright [2016-2024] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

CONTACT

Please email comments or questions to the public Ensembl
developers list at <http://lists.ensembl.org/mailman/listinfo/dev>.

Questions may also be sent to the Ensembl help desk at
<http://www.ensembl.org/Help/Contact>.

NAME

Bio::EnsEMBL::Utils::Net

SYNOPSIS

use Bio::EnsEMBL::Utils::Net qw/do_GET do_FTP/;

#Doing a HTTP get
my $google_contents = do_GET('http://www.google.co.uk/');

#Doing a FTP request; delegates onto LWP
my $ftp_contents = do_GET('https://ftp.ensembl.org/pub/current_README');

DESCRIPTION

A collection of subroutines aimed to helping network based operations. The code will use HTTP::Tiny for all HTTP operations if available. Otherwise it will delegate to LWP. LWP is currently the only supported target for FTP.

METHODS

See subroutines.

VERSION

$Revision$

do_GET

Arg [1]     : string $url The URL to fetch including all parameters
Arg [2]     : int; $total_attempts The number of times to try the URL 
              before throwing an exception
Arg [3]     : number; $sleep Amount of time to sleep between attempts. 
              Delegates onto Time::HiRes so floating point numbers are 
              supported
Description : Performs a HTTP GET method call to return the specified remote
              resource.
Returntype  : Scalar of the contents of the remote URL. Do not use to
              retrieve very large amounts of data.
Example     : my $contents = do_GET('http://www.google.co.uk/');
Exceptions  : If we could not retrieve the resource after the specified 
              number of attempts.
Status      : Stable

do_FTP

Arg [1]     : string $uri
Arg [2]     : int; $total_attempts The number of times to try the URI 
              before throwing an exception
Arg [3]     : number; $sleep Amount of time to sleep between attempts. 
              Delegates onto Time::HiRes so floating point numbers are 
              supported
Description : Performs a FTP fetch using a non-authenticated connection (
              however some servers will allow you to encode this in the URI).
Returntype  : Scalar of the contents of the remote URL. Do not use to
              retrieve very large amounts of data.
Example     : my $contents = do_GET('http://www.google.co.uk/');
Exceptions  : If we could not retrieve the resource after the specified 
              number of attempts.
Status      : Stable

do_FTP_to_file

Arg [1]     : string $uri
Arg [2]     : int; $total_attempts The number of times to try the URI 
              before throwing an exception
Arg [3]     : number; $sleep Amount of time to sleep between attempts. 
              Delegates onto Time::HiRes so floating point numbers are 
              supported
Description : Performs a FTP fetch using a non-authenticated connection (
              however some servers will allow you to encode this in the URI).
Returntype  : Boolean true if download was successful.
Example     : my $contents = do_GET('http://www.google.co.uk/');
Exceptions  : If we could not retrieve the resource after the specified 
              number of attempts.
Status      : Stable