We don't want to return from the method until the parser's been freed. We therefore need to call $parser->release() before the return statements caused by request failures.
I initially thought that we should call parse_done() whether or not parsing succeeded, but it seems that shouldn't be called when the parser has received nothing or invalid XML.
We don't want to return from the method until the parser's been freed. We therefore need to call $parser->release() before the return statements caused by request failures.
The documentation for XML::Parser::Expat says it uses data structures with circular references and release is therefore required when not called by higher level calls: https://metacpan.org/pod/distribution/libxml-enno/lib/XML/Parser/Expat.pod#release
I initially thought that we should call parse_done() whether or not parsing succeeded, but it seems that shouldn't be called when the parser has received nothing or invalid XML.
I wonder whether this is related to https://rt.cpan.org/Public/Bug/Display.html?id=41422