diff -u -r Net-Stomp-0.31/lib/Net/Stomp/Frame.pm Net-Stomp-0.31.patch/lib/Net/Stomp/Frame.pm
--- Net-Stomp-0.31/lib/Net/Stomp/Frame.pm	2006-10-11 11:29:53.000000000 -0500
+++ Net-Stomp-0.31.patch/lib/Net/Stomp/Frame.pm	2006-10-19 23:10:05.000000000 -0500
@@ -8,39 +8,13 @@
     my $self  = shift;
     my $frame = $self->command . "\n";
     while ( my ( $key, $value ) = each %{ $self->headers || {} } ) {
-        $frame .= $key . ': ' . $value . "\n";
+        $frame .= $key . ':' . $value . "\n";
     }
     $frame .= "\n";
     $frame .= $self->body || '';
     $frame .= "\000";
 }
 
-sub parse {
-    my ( $package, $string ) = @_;
-
-    my $index = index $string, "\n";
-    my $command = substr( $string, 0, $index, '' );
-    substr( $string, 0, 1, '' );
-
-    my $headers;
-
-    while (1) {
-        $index = index $string, "\n";
-        last if $index == 0;
-        my $header = substr( $string, 0, $index, '' );
-        substr( $string, 0, 1, '' );
-        my ( $key, $value ) = split /: ?/, $header, 2;
-        $headers->{$key} = $value;
-    }
-    substr( $string, 0,  1, '' );    # \n
-    substr( $string, -1, 1, '' );    # \000
-    my $body = $string;
-
-    my $frame = Net::Stomp::Frame->new(
-        { command => $command, headers => $headers, body => $body } );
-    return $frame;
-}
-
 1;
 
 __END__
diff -u -r Net-Stomp-0.31/lib/Net/Stomp.pm Net-Stomp-0.31.patch/lib/Net/Stomp.pm
--- Net-Stomp-0.31/lib/Net/Stomp.pm	2006-10-11 11:29:53.000000000 -0500
+++ Net-Stomp-0.31.patch/lib/Net/Stomp.pm	2006-10-19 23:49:55.000000000 -0500
@@ -1,4 +1,4 @@
-package Net::Stomp;
+	package Net::Stomp;
 use strict;
 use warnings;
 use IO::Socket::INET;
@@ -90,17 +90,56 @@
     my $self   = shift;
     my $socket = $self->socket;
 
-    my $string = "";
-    my $offset = 0;
-    while (1) {
-        my $len = $socket->read( $string, 1, $offset );
-        $offset += $len;
-        last if $string =~ /\000\n$/;
-    }
-
-    # warn "receive [$string]\n";
 
-    my $frame = Net::Stomp::Frame->parse($string);
+    # Read the STOMP Command.
+	$_ = "";
+	while( length == 0 ) {	    
+		unless (defined( $_ = $socket->getline ) ) {
+            die $! if $!;
+            return undef;
+        }
+        
+		# Trim
+        s/^\s+//;	    s/\s+$//;		
+	}
+	my $command = $_;
+	
+	# Read the Headers.
+    my $headers;
+    while ( 1 ) {					
+		unless (defined( $_ = $socket->getline ) ) {
+            die $! if $!;
+            return undef;
+        }
+		chop; # Strip the trailing \n
+		
+		last if length == 0;		
+        my ( $key, $value ) = split(/:/,$_,2);
+        $headers->{$key} = $value;
+    }
+    
+    my $body = "";
+    # Are we being told how much body content to read?
+    if ( defined $headers->{"content-length"} ) {
+    
+       my $length = $headers->{"content-length"};
+       my $rc = $socket->read( $body, $length);
+       
+       $socket->getc; # eat the trailing null
+       
+    } else {    
+        # nope.. got to look for the null character
+	    while ( 1 ) {	    
+    		unless (defined( $_ = $socket->getc ) ) {
+	            die $! if $!;
+	            return undef;
+	        }	        
+			last if $_ eq "\000";			
+            $body .= $_;
+	    }       
+    }
+    
+    my $frame = Net::Stomp::Frame->new( { command => $command, headers => $headers, body => $body } );
 
     # warn "[" . $frame->as_string . "]\n";
     return $frame;
