URI::F...sponse(3pm)

πŸ“¦
version 0.15 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– URI::Fetch::Response β€” the vibe is feed response πŸ’–

okay so this is a page from the User Contributed Perl Documentation set, and honestly? it's giving "tiny module, huge main character energy." it's URI::Fetch::Response(3pm), bestie. let's get into it 🫢


✨ NAME ✨

URI::Fetch::Response β€” literally just the Feed response for URI::Fetch. that's the whole name, no notes πŸ’…


🌸 SYNOPSIS 🌸

use URI::Fetch;
my $res = URI::Fetch->fetch('http://example.com/atom.xml')
    or die URI::Fetch->errstr;
print $res->content;

see how cute and small that is? you fetch, you check, you print. slay. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

URI::Fetch::Response encapsulates the response you get back from fetching a feed using URI::Fetch. it's the little wrapped-up present of "here's what the server said" πŸŽ€


πŸ‘‘ USAGE πŸ‘‘

πŸ’œ $res->content

the contents of the feed. that's it, that's the payload, the whole reason we're here 🌈

πŸ’œ $res->uri

the URI of the feed. important detail, no cap: if the feed was moved, this reflects the new URI; otherwise it'll match the URI you passed to fetch. so like, it keeps up with the drama πŸ’«

πŸ’œ $res->etag

the ETag that was returned in the response β€” if any. sometimes it's there, sometimes it ghosted you πŸ™ˆ

πŸ’œ $res->last_modified

the Last-Modified date that came back in the response, measured in seconds since the epoch β€” again, if any. same deal, it might just not show up 😭

πŸ’œ $res->status

the status of the response, and it'll match one of these enumerations, periodt:

  • URI::Fetch::URI_OK()
  • URI::Fetch::URI_MOVED_PERMANENTLY()
  • URI::Fetch::URI_GONE()
  • URI::Fetch::URI_NOT_MODIFIED()

πŸ’œ $res->http_status

the HTTP status code from the response. the raw number, bestie πŸ”’

πŸ’œ $res->http_response

the HTTP::Response object that got returned from the fetch. the whole thing, untouched ✨

πŸ’œ $res->is_success, $res->is_redirect, $res->is_error

these three are wrappers around the $res->response methods of the same name, because convenience is a love language 🫢

note, and this one actually matters: there is one difference from the behaviour of HTTP::Response. if you're using a cache and you get a 304 response, but the data is retrieved from the cache, then is_success will return true β€” because res->content is usable. so don't panic when it says success, it's correct πŸ’…

πŸ’œ $res->content_type

the Content-Type header from the response. tell me what you are, king πŸ‘‘


for author, copyright, and license info, please see the URI::Fetch manpage. all the credits live over there, go give them their flowers πŸ’


and that's the whole page, bestie!! this was perl v5.32.1, dated 2021-09-16, and it ate fr fr. mwah πŸ’‹ ✨

πŸ“¦ where this page comes from