in reply to Re^5: Again on SOAP::Lite, MIME::Entity and SOAP::Packager
in thread Again on SOAP::Lite, MIME::Entity and SOAP::Packager

SUCCESS! Your code works great.. this actually fix the wrong behaviour:

my $old_stringify_body = \&MIME::Entity::stringify_body; *MIME::Entity::stringify_body = sub { my( $self ) = @_; my $body = &$old_stringify_body; $body =~ s!\n!\r\n!g; return $body };

Replies are listed 'Best First'.
Re^7: Again on SOAP::Lite, MIME::Entity and SOAP::Packager
by Corion (Patriarch) on Dec 29, 2016 at 12:04 UTC

    Thanks for confirming this. I'm not sure whether patching ->stringify_body is the best approach in general. I've looked through the test suite and the test suite caters in various locations for output being different sizes depending on whether Perl uses \n or \r\n when writing text files without binmode. This makes me feel that the whole test suite would also need an overhaul together with the module to produce identical output regardless of where it is run.

    As I don't have a (direct) use case for MIME::tools beyond MIME::Parser and thus don't know what the applicable RFCs say, it's hard to tell (and fix) the situations where \n is used wrongly. Hopefully your investigations and findings here help others encountering SOAP problems address these issues.

      I just modified the sub only to change multipart boundaries. There is the case where binary encoded data are in the body with '\n' char and I don't want to mess with those
      my $old_stringify_body = \&MIME::Entity::stringify_body; *MIME::Entity::stringify_body = sub { my( $self ) = @_; my $body = &$old_stringify_body; $body=~/(----+=_\d+-\d+-\d)/; my $boundary=$1; $body =~ s!\n$boundary\n!\r\n$boundary\r\n!g; return $body };
      Great thanks Corion for the help!