Subject: | suggest URI::data constructor |
Date: | Thu, 18 Jul 2019 15:45:47 +1000 |
To: | bug-URI [...] rt.cpan.org |
From: | Kevin Ryde <user42_kevin [...] yahoo.com.au> |
As an idea for a feature, it could be good for URI::data to have a
constructor taking bytes and optional media type, eg.
$uri = URI::data->new($bytes, 'image/png');
This would be the 3-line create and fill combination shown in the
URI::data SYNOPSIS, and would be like what URI::file offers.
No-one would depend on URI::data->new currently going plain URI->new
would they ? I'd imagine not, but a different method name could be fine
if really worried.
Maybe key/value pairs would be handy for media type parameters,
URI::data->new($bytes, 'text/plain', charset => 'iso-8859-1');
same as
URI::data->new($bytes, 'text/plain;charset=iso-8859-1');
But maybe they're used too infrequently to want to worry for now.
(And it might make you have to think about the other direction,
splitting a string into key/values, which I presume would be already
buried somewhere in HTTP::Headers etc ...)