ePages 6.17.12 - DE_EPAGES/Core/API/Net.pm

Package DE_EPAGES::Core::API::Net

Functions for TCP/IP networking.

@EXPORT_OK
Ip2Int
Int2Ip
GetHttpResponse
GetHttpContent
localhostName
SupportedIpVersions
GetFile
GetFastestEpagesMirror
ExistsURLFile

Functions

ExistsURLFile
GetFastestEpagesMirror
GetFile
GetHttpContent
GetHttpResponse
Int2Ip
Ip2Int
SupportedIpVersions
localhostName

ExistsURLFile

check if file exists

Syntax
my $Exists = ExistsURLFile($Url, $FileName);
Input
$Url (string)
location of file
Return
$FileExists (bool)
true if file exists

GetFastestEpagesMirror

Returns the fastest URL to $RelativePath from a list of epages mirrors, e.g.: http://epages.com/RPMS/$RelativePath. If envvar EPAGES_PATCH_DATA_REPO is set, prefer that mirror (space-separated URL or absolute path). If envvar EPAGES_REPO is set, prefer that mirror (rather than EPAGES_PATCH_DATA_REPO). Example: EPAGES_PATCH_DATA_REPO=/my/repos; EPAGES_REPO=http://epages.com/RPMS Result: http://epages.com/RPMS is used Example: EPAGES_PATCH_DATA_REPO=/my/repos; EPAGES_REPO= Result: /my/repos is used Otherwise, find mirrors in default places.

Syntax
$Url = GetFastestEpagesMirror($RelativePath);
Example
my $Url = GetFastestEpagesMirror('patch/6.14.3/epages-6.14.3-patch-data.tar.gz');
returns: http://epages.com/RPMS/patch/6.14.3/epages-6.14.3-patch-data.tar.gz
Input
$RelativePath (string)
find fastest mirror for file
Return
$Url (string)
fastest mirror to file

GetFile

Loads a file from internet via HTTP "GET" request and saves it to filename.

Syntax
my $ResponseCode = GetFile($Url, $FileName);
my $ResponseCode = GetFile($Url, $FileName, $Timeout);
Input
$Url (string)
location of file
$Filename (string)
name of file
$timeout (integer)
(optional) timeout in seconds
Return
$ResponseCode (string)
if all is right 0, else http response code

GetHttpContent

Load document from internet.

Syntax
$Content = GetHttpContent($Url);
Input
$Url (string)
location of document
Return
$Content (String)
http response content (undef if http-return-code is not 200)

GetHttpResponse

Loads a document from internet via HTTP "GET" request.

Syntax
$Response = GetHttpResponse($Url);
$Response = GetHttpResponse($Url, $Timeout);
$Response = GetHttpResponse($Url, $Timeout, $UserAgentString);
Input
$Url (string)
location of document
$Timeout (integer)
(optional) timeout in seconds
$UserAgentString (string)
(optional) UserAgent header used in request
Return
$Response (HTTP::Response)
http response object

Int2Ip

Converts an integer to an IP.

Syntax
$IP = Int2Ip($IP);
Input
$Int (integer)
integer representation of the ip
Return
$IP (string)
ip string

Ip2Int

Converts an ip to an integer.

Syntax
$Int = Ip2Int($IP);
Input
$IP (string)
ip string
Return
$Int (integer)
integer representation of the ip

SupportedIpVersions

Returns an array of address families containing one/more of: 6 (for IPv6), 4 (for IPv4)

Syntax
@IpVersions = SupportedIpVersions();
Return
@IpVersions (array)
supported address families

localhostName

Returns the name of localhost: - ipv6-localhost: if UNIX and IPv6 works - localhost: otherwise

Syntax
$localhost = localhostName();
Return
$localhost (string)
localhost name