From 26c40f989b46dc0b9ea987fe29a017be3560f1dd Mon Sep 17 00:00:00 2001 From: Matt Sergeant Date: Fri, 20 May 2005 12:39:29 +0000 Subject: [PATCH] Fix for in-memory code writing headers twice git-svn-id: https://svn.perl.org/qpsmtpd/trunk@423 958fd67b-6ff1-0310-b445-bb7760255be9 --- lib/Qpsmtpd/Transaction.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 6fe8596..a6dc3be 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -64,6 +64,17 @@ sub notes { sub set_body_start { my $self = shift; $self->{_body_start} = $self->body_current_pos; + if ($self->{_body_file}) { + $self->{_header_size} = $self->{_body_start}; + } + else { + $self->{_header_size} = 0; + if ($self->{_body_array}) { + foreach my $line (@{ $self->{_body_array} }) { + $self->{_header_size} += length($line); + } + } + } } sub body_start { @@ -123,6 +134,7 @@ sub body_write { foreach my $line (@{ $self->{_body_array} }) { $self->{_body_file}->print($line) or die "Cannot print to temp file: $!"; } + $self->{_body_start} = $self->{_header_size}; } $self->{_body_array} = undef; } @@ -160,6 +172,7 @@ sub body_getline { } else { return unless $self->{_body_array}; + $self->{_body_current_pos} ||= 0; my $line = $self->{_body_array}->[$self->{_body_current_pos}]; $self->{_body_current_pos}++; return $line;