• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

keitaircメインレポジトリ


Commit MetaInfo

修订版5e1d0765eae05f40532e07e77f3ad7000741796c (tree)
时间2010-11-30 22:21:19
作者ISHIKAWA Mutsumi <ishikawa@hanz...>
CommiterISHIKAWA Mutsumi

Log Message

add get_pending method and cleanup

更改概述

差异

--- a/lib/POE/Filter/HTTPD/Keitairc.pm
+++ b/lib/POE/Filter/HTTPD/Keitairc.pm
@@ -13,11 +13,13 @@ use warnings;
1313
1414 use base qw(POE::Filter::HTTPD);
1515
16-sub STRM() { 6 } # raw data buffer to build requests
16+my $_STRM_IDX = 6;
17+sub STRM() { $_STRM_IDX } # raw data buffer to build requests
1718
1819 sub new {
1920 my $class = shift;
2021 my $me = POE::Filter::HTTPD->new;
22+ $_STRM_IDX = $#{$me} + 1;
2123 $me->[STRM] = '';
2224
2325 return bless $me, $class;
@@ -32,20 +34,32 @@ sub get_one_start {
3234 sub get_one {
3335 my ($me) = @_;
3436
37+ warn $me->[STRM],"\n";
3538 my $req = $me->SUPER::get_one();
3639
37- if(defined $req->[0]
38- && $req->[0]->header('Upgrade')
39- && $req->[0]->header('Upgrade') eq 'WebSocket'
40- && $req->[0]->header('Connection')
41- && $req->[0]->header('Connection') eq 'Upgrade') {
42- warn $me->[STRM];
43- if ($me->[STRM] =~ /\r\n\r\n(.{8})$/) {
44- warn $1;
45- $req->[0]->content($1);
40+ if(defined $req->[0]) {
41+ if ($req->[0]->header('Upgrade')
42+ && $req->[0]->header('Upgrade') eq 'WebSocket'
43+ && $req->[0]->header('Connection')
44+ && $req->[0]->header('Connection') eq 'Upgrade') {
45+ if ($me->[STRM] =~ /\r\n\r\n(.{8})$/) {
46+ $req->[0]->content($1);
47+ }
4648 }
49+ $me->[STRM] = '';
4750 }
4851 return $req;
4952 }
5053
54+sub get_pending {
55+ my ($me) = @_;
56+ if (length($me->[STRM])) {
57+ my $buf = $me->[STRM];
58+ $me->[STRM] = '';
59+ return [$buf];
60+ } else {
61+ return undef;
62+ }
63+}
64+
5165 1;