Re: "End of file found" error

2007-06-10 Thread Raymond Wan


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 = [EMAIL PROTECTED]>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:

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




Submit
Clear



test2.html:

<%args>
$filename
$keyword

<%perl>
print $filename, "";
print $keyword, "";

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


<%
#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

2007-06-10 Thread Joe Schaefer
Raymond Wan <[EMAIL PROTECTED]> 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



Re: "End of file found" error

2007-06-11 Thread Raymond Wan


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 for file uploading

2007-06-10 Thread Joe Schaefer
Raymond Wan <[EMAIL PROTECTED]> writes:

> I enable apreq2 and then tried this:
>
> my $contents = '';
> my $req = Apache2::Request -> new ($r);
> my $upload = $req->upload ('foo');
> my $size = $upload -> slurp($contents);
>
> with a form using the "post" method and an enctype of
> "multipart/form-data". 
>
> In my browser, I am getting a single message: "End of file found".
> That is, the single line.

What's happening is that $req->upload calls $req->body, and that is
die'ing with the "End of file found" error.  What browser are you using,
and what version of apreq?

(The problem you're seeing is either a bug in apreq's mfd parser, 
or in what your browser is actually emitting).

-- 
Joe Schaefer


Re: "End of file found" error for file uploading

2007-06-10 Thread Raymond Wan


Hi Joe,

Joe Schaefer wrote:

with a form using the "post" method and an enctype of
"multipart/form-data". 


In my browser, I am getting a single message: "End of file found".
That is, the single line.



What's happening is that $req->upload calls $req->body, and that is
die'ing with the "End of file found" error.  What browser are you using,
and what version of apreq?
  


Oh!  I see.  After I read your message, I tried other browsers and while 
all browsers could be wrong, I got the same error.  First, I was using 
Iceweasel 2.0.0.3 and then I tried the Gnome Web Browser (Epiphany) 
2.14.3 and even Elinks 0.11.X, all running on Debian and the same 
machine that the server is on (I'm testing locally).


apreq2 is version 2.08.4 on Debian stable (testing seems to have a 
2.08.5...).


Any suggestions on how I can resolve the problem?  Could there be 
something wrong in the server set-up, etc.?  As I said, it's all 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?


Thank you for your reply!

Ray




Re: "End of file found" error for file uploading

2007-06-10 Thread Joe Schaefer
Raymond Wan <[EMAIL PROTECTED]> writes:

> apreq2 is version 2.08.4 on Debian stable (testing seems to have a
> 2.08.5...). 

Hmm, that's the latest version.  I don't think debian has applied any
local mods to the codebase.

> Any suggestions on how I can resolve the problem?  Could there be
> something wrong in the server set-up, etc.?  As I said, it's all
> 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 = [EMAIL PROTECTED]>upload("foo"); # won't die this time
   }
   ...

and try to see where the form data is getting lost.


-- 
Joe Schaefer