application/octet-stream and empty fileinputs
am 04.03.2006 01:05:31 von ekolve
------=_Part_16829_32400037.1141430731727
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
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. I compared dumps of firefox vs. LWP and it
looks like firefox does set the content-type even if you don't have anythin=
g
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.
thanks,
eric
------=_Part_16829_32400037.1141430731727--
Re: application/octet-stream and empty fileinputs
am 04.03.2006 10:49:56 von gisle
"Eric Kolve" 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
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