WWW::Noss::Curl − Interface to curl command
use
WWW::Noss::Curl qw(curl);
curl('https://url', 'output');
WWW::Noss::Curl is a module that provides an interface to the curl(1) command for fetching network resources. This is a private module, please consult the noss manual for user documentation.
Subroutines are
not automatically exported.
($rt, \@resp, \%head) = curl($link, $output, [ %param ])
curl(1) $link and download it to $output. %param is an optional hash argument of additional parameters to pass.
Returns the exit code of curl(1). A return value of 0 means success, non−zero means failure. curl_error() can be used to describe the return value. Also returns the return values of parse_http_header() on the reponse's header.
The following
are valid fields for the %param hash:
verbose
Boolean determining whether to enable verbose output or not. Corresponds to curl(1)'s "−−silent" option. Defaults to false.
agent
String to use as user agent. Corresponds to curl(1)'s "−−user−agent" option. Defaults to none.
time_cond
Only download a file if it has been modified past the given time. Can either be a timestamp or file. Corresponds to curl(1)'s "−−time−cond" option. Defaults to none.
remote_time
Copy the remote file's modification time when downloading a file. Corresponds to curl(1)'s "−−remote−time" option. Defaults to false.
etag_save
Path to file to write remote file's etag to, if it has one. Corresponds to curl(1)'s "−−etag−save" option. Defaults to none.
etag_compare
Path to file to compare remote file's etag to, only downloading the remote file if the etags differ. Corresponds to curl(1)'s "−−etag−compare" option. Defaults to none.
limit_rate
Download rate to limit curl(1) to. Corresponds to curl(1)'s "−−limit−rate" option. Defaults to none.
user_agent
User agent string to send to server. Corresponds to curl(1)'s "−−user−agent" option. Defaults to none.
timeout
Maximum time in seconds a transfer is allowed to take. Corresponds to curl(1)'s "−−max−time" option. Defaults to no timeout.
fail
Boolean determining if curl(1) should fail with no output on server errors. Corresponds to curl(1)'s "−−fail" option. Defaults to false.
proxy
Host to use as proxy. Corresponds to curl(1)'s "−−proxy" option. Defaults to none.
proxy_user
Username and password to use for proxy, separated by a colon ("user:pwd"). Corresponds to curl(1)'s "−−proxy−user" option. Defaults to none.
redirect
Boolean determining whether to following redirections. Corresponds to curl(1)'s "−−location" option. Defaults to false.
$desc = curl_error($rt)
Returns the string description of the curl() exit code $rt.
(\@response, \%head) = parse_http_header($header)
Parses the HTTP header in $header. "\@response" is an array ref containing the reponses's information. The first element is the protocol information, the second is the HTTP status code, and the third is a string providing extra information about the reponse. "\%head" is a hash of data provided by the response's header fields.
$desc = http_status_string($code)
Returns the string description of the HTTP status code $code. Dies if $code is not a valid status code.
%WWW::Noss::Curl::CODES
Hash of curl() exit codes and their corresponding string descriptions. Use of the curl_error() function is preferable.
Written by Samuel Young, <[email protected]>.
This project's source can be found on its Codeberg page <https://codeberg.org/1-1sam/noss.git>. Comments and pull requests are welcome!
Copyright (C) 2025 Samuel Young
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 3 of the License, or (at your option) any later version.
curl(1), noss