Re: application/octet-stream and empty fileinputs

Gisle Aas <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
"Eric Kolve" <[email protected]> writes:

> I noticed that if you submit an HTML::Form that it doesn't set the
> content-type for empty fileinputs to application/octet-stream.  I am not
> sure if this is legal or not.

The reported content type is determined by looking at the file name
extension and if not recongnized by what perl's -T builtin thinks.  On
my system -T regards empty files as text, so empty files are reported
as text/plain.

This program:

 use HTML::Form;
 my $f = HTML::Form->parse(<<EOT, "http://www.example.com");
 <form method="POST" enctype="multipart/form-data">
   <input name=f value="/dev/null" type="file">
 </form>
 EOT
 print $f->click->as_string;

will for instance print:

 POST http://www.example.com
 Content-Length: 114
 Content-Type: multipart/form-data; boundary=xYzZY

 --xYzZY
 Content-Disposition: form-data; name="f"; filename="/dev/null"
 Content-Type: text/plain


 --xYzZY--

Your message seems to indicate that you get no Content-Type at all.
Please provide some example code that demonstrates how you use the
module.

>                                  I compared dumps of firefox vs. LWP and it
> looks like firefox does set the content-type even if you don't have anything
> for the input stream.  I suppose since the content is empty you *SHOULDN'T*
> have to set a content-type, but I am curious to hear opinions on whether
> this should be changed.

If you find differences that make real world applications break with
LWP that works with Firefox then I would certainly like to fix LWP.

Regards,
Gisle
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.