"C.J. Collier" <[EMAIL PROTECTED]> writes:

> The program in question is Persists Software's Asp Upload.  When
> I mailed the president of Persists software, he told me that the reason
> his product does not comply with the RFC's suggestion of 2 - characters
> is because all major browsers send a minimum of 10 - characters.
> 
> The way we got around the issue was to hack Common.pm and hardcode 12 -
> characters to preceed all MIME-encoded data.
> 
> This makes for difficult upgrades, of course.  :)  I was hoping that an
> argument could be added to the module to specify the number of -
> characters to preceed MIME-encoded data, but still default to 2 if the
> argument was not specified.  Does anyone see any issues that may arise
> from this?

What I think you want is to be able to specify your own suggested
boundary string.  After this patch HTTP::Request::Common allow you to
do that.  This example show how to use it:

    use HTTP::Request::Common qw(POST);
    my $r = POST("http://www.perl.com",
                 Content_Type => 'multipart/form-data; 
boundary="--------------------"',
                 Content => {
                                a => xYzZY,
                                c => 34,
                            }
                );
    print $r->as_string;
    ___END__

Regards,
Gisle


Index: lib/HTTP/Request/Common.pm
===================================================================
RCS file: /home/cvs/aas/perl/mods/libwww-perl/lib/HTTP/Request/Common.pm,v
retrieving revision 1.16
retrieving revision 1.18
diff -u -p -c -r1.16 -r1.18
*************** sub POST
*** 45,55 ****
      }
  
      if (ref $content) {
!       if (lc($ct) eq 'multipart/form-data') {    #XXX: boundary="..."
            my $boundary;
            ($content, $boundary) = form_data($content, $boundary);
!           $boundary = qq("$boundary") if $boundary =~ /\W/;
!           $ct = qq(multipart/form-data; boundary=$boundary);
        } else {
            # We use a temporary URI object to format
            # the application/x-www-form-urlencoded content.
--- 45,76 ----
      }
  
      if (ref $content) {
!       if ($ct =~ m,^multipart/form-data\s*(;|$),i) {
!           require HTTP::Headers::Util;
!           my @v = HTTP::Headers::Util::split_header_words($ct);
!           Carp::carp("Multiple Content-Type headers") if @v > 1;
!           @v = @{$v[0]};
! 
            my $boundary;
+           my $boundary_index;
+           for (my @tmp = @v; @tmp;) {
+               my($k, $v) = splice(@tmp, 0, 2);
+               if (lc($k) eq "boundary") {
+                   $boundary = $v;
+                   $boundary_index = @v - @tmp - 1;
+                   last;
+               }
+           }
+ 
            ($content, $boundary) = form_data($content, $boundary);
! 
!           if ($boundary_index) {
!               $v[$boundary_index] = $boundary;
!           } else {
!               push(@v, boundary => $boundary);
!           }
! 
!           $ct = HTTP::Headers::Util::join_header_words(@v);
        } else {
            # We use a temporary URI object to format
            # the application/x-www-form-urlencoded content.
*************** L<HTTP::Request>, L<LWP::UserAgent>
*** 379,385 ****
  
  =head1 COPYRIGHT
  
! Copyright 1997-1998, Gisle Aas
  
  This library is free software; you can redistribute it and/or
  modify it under the same terms as Perl itself.
--- 400,406 ----
  
  =head1 COPYRIGHT
  
! Copyright 1997-2000, Gisle Aas
  
  This library is free software; you can redistribute it and/or
  modify it under the same terms as Perl itself.

Reply via email to