use PublicInbox::Msgmap;
use PublicInbox::GitCatFile;
use PublicInbox::MID qw(mid2path);
-use Email::Simple;
+use Email::MIME;
use Data::Dumper qw(Dumper);
use POSIX qw(strftime);
use Time::HiRes qw(clock_gettime ualarm CLOCK_MONOTONIC);
sub new ($$$) {
my ($class, $sock, $nntpd) = @_;
my $self = fields::new($class);
+ binmode $sock, ':utf8'; # RFC 3977
$self->SUPER::new($sock);
$self->{nntpd} = $nntpd;
res($self, '201 server ready - post via email');
}
found:
my $o = 'HEAD:' . mid2path($mid);
- my $s = eval { Email::Simple->new($ng->gcf->cat_file($o)) };
+ my $bytes;
+ my $s = eval { Email::MIME->new($ng->gcf->cat_file($o, \$bytes)) };
return $err unless $s;
if ($set_headers) {
$s->header_set('Newsgroups', $ng->{name});
# must be last
if ($set_headers == 2) {
- $s->header_set('Bytes', bytes::length($s->as_string));
+ $s->header_set('Bytes', $bytes);
$s->body_set('');
}
}
if (MSG_MORE && !$self->{write_buf_size}) {
my $n = send($self->{sock}, $data, MSG_MORE);
if (defined $n) {
- my $dlen = bytes::length($data);
+ my $dlen = length($data);
return 1 if $n == $dlen; # all done!
- $data = bytes::substr($data, $n, $dlen - $n);
+ $data = substr($data, $n, $dlen - $n);
}
}
$self->do_write($data);
}
return $self->close if $r < 0;
- my $len = bytes::length($self->{rbuf});
+ my $len = length($self->{rbuf});
return $self->close if ($len >= LINE_MAX);
}