in reply to amelinda's HTTP/MIME/file upload/not-a-cgi-but-a-client/minimal-module/perl problem

Are you sure Content-length is just the length of each item of content? I was always under the impression that this specified the amount of data the server was going to have to read after you were done with your headers. If so, you have to include all of your additional MIME headers, boundaries, etc.

I'm not 100% certain about this, but it is consistent with your symptoms, so I thought I'd mention it.

  • Comment on Re: amelinda's HTTP/MIME/file upload/not-a-cgi-but-a-client/minimal-module/perl problem
  • Download Code

Replies are listed 'Best First'.
RE: Re: amelinda's HTTP/MIME/file upload/not-a-cgi-but-a-client/minimal-module/perl problem
by amelinda (Friar) on Sep 30, 2000 at 03:11 UTC
    Right. That's why the next line is $len += 514;. It accounts for those extra bits (since they remain constant throughout all invocations of the code).
      We've been going back and forth in the Chatterbox for a bit, and I know you're pretty sure that 514 number is accurate, but I still think it isn't. I modified your code to append everything after your HTTP headers to $data, and added these two lines:
      print "\$len=$len\n"; print "data length=" . length($data) . "\n";
      Now in theory, these should be the same, but they aren't:
      (fastolfe) eddie:~$ perl test user password test.file $len=555 data length=580
      Try adding 25 to your number and see if your problem goes away.. *shrug*.
        I changed the code so that it puts the entire output into a string, does a $len = (length $output), and then prints $len and $output. If that isn't the right number, I'll eat my hat*.

        amelinda

        * I am prefectly safe in this, as I own no hats. No, wait, I own a pith helmet, and I'm not going to eat that... uhm, if that isn't the right number, I'll eat.... soybeans, yeah that's it.**

        ** Mmmmm, edomame.

      Oh.