[icinga-checkins] icinga.org: icinga-core/mfriedrich/cgis: Add get_body function to seperate header from body

git at icinga.org git at icinga.org
Sat Feb 25 15:48:05 CET 2012


Module: icinga-core
Branch: mfriedrich/cgis
Commit: 170bf2c185aefe8563f24e33eb04ecc3bf07c9ef
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=170bf2c185aefe8563f24e33eb04ecc3bf07c9ef

Author: Alexander Wirt <formorer at debian.org>
Date:   Sat Feb 25 09:32:15 2012 +0100

Add get_body function to seperate header from body

---

 t/Icinga/Test.pm |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/t/Icinga/Test.pm b/t/Icinga/Test.pm
index 3348cc2..44dc96c 100644
--- a/t/Icinga/Test.pm
+++ b/t/Icinga/Test.pm
@@ -6,7 +6,7 @@ use strict;
 use warnings;
 
 use Exporter 'import';
-our @EXPORT_OK = qw( run_cgi);
+our @EXPORT_OK = qw( run_cgi get_body );
 
 use IPC::Run3 qw( run3 );
 
@@ -34,4 +34,16 @@ sub run_cgi ($$$$) {
     return $out;
 }
 
+sub get_body ($) {
+    my $output = shift;
+    # remove cr from output
+    $output =~ s/\r//g;
+    my $body; my $flag = 0;
+    foreach my $line (split("\n", $output)) {
+        $flag = 1 if $line =~ /^$/;
+        $body .= $line if $flag;
+    }
+    return $body;
+}
+
 1;





More information about the icinga-checkins mailing list