]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
handle fragmented reads on the socket
authorAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Feb 2007 16:44:04 +0000 (16:44 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Fri, 23 Feb 2007 16:44:04 +0000 (16:44 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4358 d0543943-73ff-0310-b7d9-9358b9ac24b2

scripts/socket/FreeSWITCH/Client.pm

index 91282caee81fe4f1caa5707dd94f755e3d93cdbc..96daddd325c4c8f94e5c7d9916147b38a796484c 100644 (file)
@@ -42,7 +42,6 @@ sub readhash($;$) {
        if ($i eq "") {   
          $h->{socketerror} = "yes";
          return $h;
-         last;
        } elsif ($i eq "\n") {
          $crc++;
          last;
@@ -51,6 +50,7 @@ sub readhash($;$) {
        }
        $line .= $i;      
       }
+
       if (!$line) {
        last;
       }
@@ -67,7 +67,15 @@ sub readhash($;$) {
     }
     
     if ($h->{'content-length'}) {
-      recv $s, $h->{body}, $h->{'content-length'}, 0;
+      while(length($h->{body}) < $h->{'content-length'}) {
+       my $buf;
+       recv $s, $buf, $h->{'content-length'}, 0;
+       if (!$buf) {
+         $h->{socketerror} = "yes";
+         return $h;      
+       }
+       $h->{body} .= $buf;
+      }
     }
 
     if ($h->{'content-type'} eq "text/event-plain") {