Subject: | [PATCH] Fixed handling of log/data |
The handling of LOG (Content-type: log/data) is completely broken, this patch fixes this.
Subject: | FSSocket.pm.patch |
--- /usr/local/share/perl/5.20.2/POE/Filter/FSSocket.pm.org 2017-08-09 12:49:16.152302000 +0200
+++ /root/FSSocket.pm 2017-08-09 12:48:53.644302000 +0200
@@ -123,10 +123,11 @@
sub STATE_WAITING() {1} #looking for new input
sub STATE_CLEANUP() {2} #wipe out record separators
sub STATE_GETDATA() {3} #have header, get data
sub STATE_FLUSH() {4} #puts us back in wait state and tells us to kill the parsed_record
sub STATE_TEXTRESPONSE() {5} #used for api output
+sub STATE_TEXTRESPONSE_LOG() {6}
sub new {
my $class = shift;
my %args = @_;
@@ -181,11 +182,14 @@
} else {
#not engough in the buffer yet, come back later
return;
}
} else { #we are in normal line based mode
- if($self->[FRAMING_BUFFER] =~ s/^(.*?)(\x0D\x0A?|\x0A\x0D?)//) {
+ if (($self->[PARSER_STATE] == STATE_TEXTRESPONSE_LOG) &&
+ ($self->[FRAMING_BUFFER] =~ s/^User-Data:\s*(.*)$/$1/)) {
+ $self->[PARSER_STATE] = STATE_TEXTRESPONSE;
+ } elsif($self->[FRAMING_BUFFER] =~ s/^(.*?)(\x0D\x0A?|\x0A\x0D?)//) {
$line = $1;
} else {
#not enough off of the socket yet, come back later
return [];
}
@@ -223,11 +227,11 @@
$self->[PARSER_STATE] = STATE_CLEANUP;
$self->[PARSER_STATENEXT] = STATE_GETDATA;
} elsif ($1 eq "api/response") {
$self->[PARSER_STATENEXT] = STATE_TEXTRESPONSE;
} elsif ($1 eq "log/data") {
- $self->[PARSER_STATENEXT] = STATE_TEXTRESPONSE;
+ $self->[PARSER_STATENEXT] = STATE_TEXTRESPONSE_LOG;
} else { #unexpected input
croak ref($self) . " unknown input [" . $self->[PARSER_STATE] . "] (" . $line . ")";
}
} else {
#already in wait state, if we are not in strict, keep going