You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Raymond Wan <rw...@kuicr.kyoto-u.ac.jp> on 2007/06/10 19:09:07 UTC

Re: "End of file found" error

Hi Joe,

Joe Schaefer wrote:
>> running on a test machine (i.e., the web server isn't live on the
>> Internet) so perhaps I didn't set it up correctly?
>>     
>
> I really don't know, it could be the parser is just misbehaving on your
> particular html form.  What you can do to further investigate is something like
> this:
>
>    my $upload = eval { $req->upload("foo") };
>    if ($@) {
>       $upload = $@->upload("foo"); # won't die this time
>    }
>    ...
>
> and try to see where the form data is getting lost.
>   

For some reason, I am doubting my own HTML skills...or perhaps I've been 
staring at this for so long, the screen is getting blurry :-) .  
Anything here looks suspicious?

test1.html:

<form action="http://localhost/~user/test2.html" method="post" 
enctype="multipart/form-data" name="mai nform">

<input type="file" name="filename" />
<input type="text" width="10" name="keyword" />
<button type="submit">Submit</button>
<button type="reset">Clear</button>
</form>


test2.html:

<%args>
$filename
$keyword
</%args>
<%perl>
print $filename, "<br />";
print $keyword, "<br />";

my $req = Apache2::Request -> new ($r);
my @params = $req -> param ();
print scalar (@params), "\n<br />\n";
</%perl>

<%
#my $upload = $req->upload ('filename');
%>

There's some Mason in there, but basically, both $filename and $keyword 
print out ok (well, the filename), so it doesn't seem like any part of 
the form is "lost".  "scalar (@params)" is 0, though...which makes me 
think I'm doing something wrong.  Shouldn't it be 2?  And of course, if 
I move the commented line up, I get the "End of file found" error...

As much as I'd like to be like other newbies and blame either apreq2 or 
the browser and say one of them is buggy :-) ...I'm more inclined to 
believe that since other people use it, it must be something that I'm 
doing wrong.  If I remove the file input, and just leave the text box, 
then I still get the error.  So, it isn't because of the file 
uploading...  (I've changed the Subject to reflect this...)

Perhaps it's what I'm doing with Mason?

Ray

PS:  I don't mean to put you on the spot, Joe, for replying to me 
initially (which I am thankful for!).  Of course, if anyone else can 
give me their ideas, I'd appreciate it, too!



Re: "End of file found" error

Posted by Raymond Wan <rw...@kuicr.kyoto-u.ac.jp>.
Hi Joe,

Joe Schaefer wrote:
>> Anything here looks suspicious?
>>     
>
> Yes.  Your code behaves as if CGI.pm was being used by Mason instead
> of apreq.  When that happens, CGI.pm steals the post data, and
> apreq sees nothing but an "End of File" situation.
>
> If I were you, I'd double-check how you configured Mason to select
> apreq instead of CGI.pm.  That's probably where the bug lies.
>   

Thanks for the tip!  Yes, I finally found the problem.  Indeed, it was 
because of how I configured Mason -- by default, it uses CGI.pm...  No 
wonder the word "CGI" didn't appear in any of my configuration files 
when I was grepping...

Unrelated to modperl, but in case a Mason user sees the same problem as 
me, adding this line to httpd.conf will do it:

PerlSetVar MasonArgsMethod 'mod_perl'

Now, I can see the number of parameters sent and can access the uploaded 
file fine.  That's a lot of time spent for a single line...  :-)  Thanks 
for the help and the suggestion...that definitely helped me narrow 
things down!

Ray



Re: "End of file found" error

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Raymond Wan <rw...@kuicr.kyoto-u.ac.jp> writes:

> For some reason, I am doubting my own HTML skills...or perhaps I've
> been staring at this for so long, the screen is getting blurry :-) .
> Anything here looks suspicious?

Yes.  Your code behaves as if CGI.pm was being used by Mason instead
of apreq.  When that happens, CGI.pm steals the post data, and
apreq sees nothing but an "End of File" situation.

If I were you, I'd double-check how you configured Mason to select
apreq instead of CGI.pm.  That's probably where the bug lies.

-- 
Joe Schaefer