提交 bd622460 authored 作者: Anthony Minessale's avatar Anthony Minessale

handle fragmented reads on the socket

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4358 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 a644b549
...@@ -42,7 +42,6 @@ sub readhash($;$) { ...@@ -42,7 +42,6 @@ sub readhash($;$) {
if ($i eq "") { if ($i eq "") {
$h->{socketerror} = "yes"; $h->{socketerror} = "yes";
return $h; return $h;
last;
} elsif ($i eq "\n") { } elsif ($i eq "\n") {
$crc++; $crc++;
last; last;
...@@ -51,6 +50,7 @@ sub readhash($;$) { ...@@ -51,6 +50,7 @@ sub readhash($;$) {
} }
$line .= $i; $line .= $i;
} }
if (!$line) { if (!$line) {
last; last;
} }
...@@ -67,7 +67,15 @@ sub readhash($;$) { ...@@ -67,7 +67,15 @@ sub readhash($;$) {
} }
if ($h->{'content-length'}) { 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") { if ($h->{'content-type'} eq "text/event-plain") {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论