gr0f has asked for the wisdom of the Perl Monks concerning the following question:

Aight, I've gotten some replies to this problem but a solution has still not arrived. A certain part of my script needs to upload a file to a website via form based upload. Herer is the relavent Perl code:
my $req = POST ('http://www.environet.gov.on.ca/dwws-app/DWWSApp?cmd=U +ploadSubmPage.uploadSubm', Content_Type => 'form-data', Content => [ works_id => '210000586', lab_id => '48', filename => [$FileName] + ] );
There doesn't seem to be anything immediately wrong with this, and several people have confirmed that the header it generates looks ok. Yet with this generated header, the website spits back an error. The header:
POST http://www.environet.gov.on.ca/dwws-app/DWWSApp?cmd=UploadSubmPag +e.uploadSubm Content-Length: 11073 Content-Type: multipart/form-data; boundary=xYzZY --xYzZY Content-Disposition: form-data; name="works_id" 210000586 --xYzZY Content-Disposition: form-data; name="lab_id" 48 --xYzZY Content-Disposition: form-data; name="filename"; filename="210000586-2 +10001130.txt" Content-Length: 10760 Content-Type: text/plain
Produces this error response:
Malformed line after disposition: Content-Length: 10760
Perhaps there is something missing from the 'Content-Type: text/plain' line? It would be interesting to see what headers browsers like IE and Mozilla generate, since they seem to have no problem uploading these files in this manner. Got any bright ideas guys?

-Thanks, Tim

Replies are listed 'Best First'.
Re: Still Unsolved HTTP Headers Problem
by Masem (Monsignor) on Aug 28, 2001 at 19:02 UTC
    Is the space between Content-Length and "Content-Type: text/plain" yours or the program? Can you remove it manual and see what happens?

    From what I recall of HTTP headers, any \n\n in the headers indicate the end of headers and the start of data, and without a content-type explicitly defined, it spits back that error.

    -----------------------------------------------------
    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
    It's not what you know, but knowing how to find it if you don't know that's important

Re: Still Unsolved HTTP Headers Problem
by tachyon (Chancellor) on Aug 28, 2001 at 20:41 UTC

    The print $req->as_string method you are using to display this gives a *representation* of what gets sent rather than what *actually* gets sent. There is LWP::Debug qw(+); to get the full rundown of what transpires during the transaction.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Re: Still Unsolved HTTP Headers Problem
by princepawn (Parson) on Aug 28, 2001 at 19:12 UTC