Dealing with other requests
There are
untold IQ elements that could be sent to the component. While it would be
possible just to ignore them, we ought to do something and at least respond with something like “not supported.”
For that, we have iq_notimpl() as a catch-all. If the
dispatcher manages to make its way to here, we know that the
<iq/>
element is not anything we recognize as wanting to respond to.
The following can be used to tell the requester that what they’re asking for hasn’t been implemented:
sub iq_notimpl {
my $node = shift;
$node = toFrom($node);
$node->attr('type', IQ_ERROR);
my $error = $node->insertTag('error');
$error->attr('code', '501');
$error->data('Not Implemented');
$c->send($node);
return r_HANDLED;
}
As you can see, all this does is set the <iq/>
type to error, switches the from
and to, and adds an
<error/> tag:
<error code='501'>Not Implemented</error>
The modified element is sent back to the requester. This lets them know that they’ve requested something that just isn’t there or hasn’t been implemented yet.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access