[Catalyst-commits] r7646 -
Catalyst-Engine-XMPP2/trunk/lib/Catalyst/Engine
ruoso at dev.catalyst.perl.org
ruoso at dev.catalyst.perl.org
Wed Apr 30 01:44:32 BST 2008
Author: ruoso
Date: 2008-04-30 01:44:32 +0100 (Wed, 30 Apr 2008)
New Revision: 7646
Modified:
Catalyst-Engine-XMPP2/trunk/lib/Catalyst/Engine/XMPP2.pm
Log:
[C-E-XMPP2] More friendly closures. Fixes the iq_reply_result/error call.
Modified: Catalyst-Engine-XMPP2/trunk/lib/Catalyst/Engine/XMPP2.pm
===================================================================
--- Catalyst-Engine-XMPP2/trunk/lib/Catalyst/Engine/XMPP2.pm 2008-04-30 00:42:45 UTC (rev 7645)
+++ Catalyst-Engine-XMPP2/trunk/lib/Catalyst/Engine/XMPP2.pm 2008-04-30 00:44:32 UTC (rev 7646)
@@ -145,8 +145,10 @@
$request->content_length( length($content) );
$request->content( $content);
+ #$app->log->debug('[Request Content] '.$request->content);
my $response;
+
$app->handle_request($request, \$response);
my %response_attrs = map { $_ => $response->header('XMPP_Stanza_'.$_) }
@@ -155,14 +157,18 @@
if ($response->is_success && $type ne 'iq') {
#$app->log->debug('Request ended successfully, no response needed.');
} elsif ($response->is_success) {
+ my $content_type = $response->header('Content-type');
+ my $content_raw = $response->content();
$self->connections->{$resource}->reply_iq_result
- ($node->attr('id'), sub {
+ ($node, sub {
my $xml_writer = shift;
- if ($response->header('Content-type') &&
- $response->header('Content-type') =~ /xml/) {
- $xml_writer->raw($response->content);
+ my $ctype = $content_type;
+ my $craw = $content_raw;
+ if ($ctype &&
+ $ctype =~ /xml/) {
+ $xml_writer->raw($craw);
} else {
- $xml_writer->raw('<body>'.$response->content.'</body>');
+ $xml_writer->raw('<body>'.$craw.'</body>');
}
}, %response_attrs);
} else {
@@ -175,14 +181,15 @@
}
if ($node->name eq 'iq') {
$self->connections->{$resource}->reply_iq_error
- ($node->attr('id'), $type, $cond, %response_attrs);
+ ($node, $type, $cond, %response_attrs);
} else {
+ my $content_raw = $response->content();
$self->connections->{$resource}->send_message
($node->attr('from'), 'error', sub {
my $xml_writer = shift;
$xml_writer->raw($content.'<error type="'.$type.'">'.
'<'.$cond.' xmlns=\'urn:ietf:params:xml:ns:xmpp-stanzas\'/>'.
- '<text>'.$response->content.'</text></error>');
+ '<text>'.$content_raw.'</text></error>');
} , %response_attrs);
}
}
More information about the Catalyst-commits
mailing list