Re: $r->content

2002-09-25 Thread Rodney Broom

From: Geoffrey Young <[EMAIL PROTECTED]>


GY> I didn't think that was what he was asking about.  getting the POST 
GY> data from the main request in a subrequest is generally easy with 
GY> Apache::Request:

Oops, you're right. I was thinking that Mark (jump in any time) needed to keep things 
in POST to satisfy some upcoming code. Some things insist on POST only. Worse, some 
things need POST data and use r->args for other purposes all together.

I guess the example I was thinking of in my head is where I have to do something like 
redirecting the user to a login page when their authentication runs out, then still 
honor their original request (including POST data) without them having to intervene.


---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r->content

2002-09-25 Thread Geoffrey Young



Rodney Broom wrote:
 > MC> > Presently I get all the incoming parameters via
 > Apache::Request and MC> > append to the URL before redirecting but
 > this is not ideal as I?d like MC> > to spit the modified parameters
 > out in a POST. Can anyone give me any MC> > advice?
 >
 > GY> see GY>
 > http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_POS-
 > T_Requests
 >
 >
 > I thought I recalled a $STDIN var in mod_perl, but didn't find
 > anything with a quick scan of the docs. If that var ~is~ available,
 > and writable, and are doing an internal redirect, you might be able
 > to just reload it:
 >
 > $STDIN = $r->content; $r->internal_redirect_handler($handler);
 >
 >
 > I know I've done this sort of thing (redirecting POSTs) with a
 > session system. That is, a handler early in the request that sets
 > up POST data, then everything else uses only that source:
 >

I didn't think that was what he was asking about.  getting the POST 
data from the main request in a subrequest is generally easy with 
Apache::Request:

   my $r = shift;
   $r = Apache::Request->instance( $r->is_main ? $r : $r->main );

or somesuch.

if you want to manipulate the data from one subrequest to another I 
suspect something like

   $r->param->set(foo => bar)

would work with the above is_main() syntax, but I haven't tested it 
(I'm tired too :)

so perhaps turning the request into a GET is easier.

--Geoff




Re: $r->content

2002-09-25 Thread Rodney Broom

MC> > Presently I get all the incoming parameters via Apache::Request and 
MC> > append to the URL before redirecting but this is not ideal as I?d like 
MC> > to spit the modified parameters out in a POST. Can anyone give me any 
MC> > advice?

GY> see
GY> http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_POST_Requests


I thought I recalled a $STDIN var in mod_perl, but didn't find anything with a quick 
scan of the docs. If that var ~is~ available, and writable, and are doing an internal 
redirect, you might be able to just reload it:

  $STDIN = $r->content;
  $r->internal_redirect_handler($handler);


I know I've done this sort of thing (redirecting POSTs) with a session system. That 
is, a handler early in the request that sets up POST data, then everything else uses 
only that source:

  # My::STDINHandler
  use Storable;
  sub handler {
store({content => $r->content}, $unique_file_location);
  }

  sub content {
return retrieve($unique_file_location)->{content}
  if $some_good_tests;
return Apache->request->content;
  }


  # My script
  $content = My::STDINHandler::content();



I apologize for any inconsistencies in this message, I'm a bit tired and the coffee 
isn't strong enough today.

---
Rodney Broom
President, R.Broom Consulting
http://www.rbroom.com/





Re: $r->content

2002-09-25 Thread Geoffrey Young


> Presently I get all the incoming parameters via Apache::Request and 
> append to the URL before redirecting but this is not ideal as I?d like 
> to spit the modified parameters out in a POST. Can anyone give me any 
> advice?

see

http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_POST_Requests

for an example that may help.

HTH

--Geoff





$r->content

2002-09-25 Thread Mark Cance
Title: $r->content



I’m trying to read some posted data, modify it and then redirect request inc the modified data. Something like;

my $r = Apache::Request->new(Apache->request);
my %form = $r->content;
#modify %form
$r->content(%form);
$r->internal_redirect_handler($some_page);

That’s the ideal but from some tests I’ve done it would seem that content() takes no args and so cannot be used in this way.

Presently I get all the incoming parameters via Apache::Request and append to the URL before redirecting but this is not ideal as I’d like to spit the modified parameters out in a POST. Can anyone give me any advice?

Thanks. 






Re: $r->args vs $r->content

2002-05-14 Thread Richard Clarke

Are you also processing the posted data at some earlier request stage? It
doesn't sound like you would be but I thought I would ask.

Richard


- Original Message -
From: Mike Melillo
To: [EMAIL PROTECTED]
Sent: Tuesday, May 14, 2002 5:22 PM
Subject: $r->args vs $r->content





Ok, I've switched to A::Request, but it still seems my parameters table is
empty.  I'll paste in the form data, as well as some code snippets to see if
that helps find the bug.

 

username



password






**End HTML Template**

** Join.pm **

sub submit {
my $DEBUG = 1;
my ($r) = shift;
my $apr = Apache::Request->new($r);
my $status = $apr->parse;
my @param = $apr->param;
$DEBUG && print STDERR Dumper($apr->parms)
$DEBUG && print STDERR Dumper(@param);

...
}


The first Data::Dumper print statement sends this to the errlog ->
$VAR1 = bless( {}, 'Apache::Table' );

The second print statement prints nothing.

I looked at perldoc Apache::Request, but didn't see anything wrong...

Help?

Mike



-Original Message-
From: Issac Goldstand [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 14, 2002 4:39 AM
To: Mike Melillo
Cc: [EMAIL PROTECTED]
Subject: Re: $r->args vs $r->content

Quoting Mike Melillo <[EMAIL PROTECTED]>:

>
> Hi,
>

> One of the fields is an image file that will be uploaded so I need to
> use POST requests.  Is this a job for Apache::Request?  The eagle book
> doesn't cover it much because it was "experimental" at the time of
> publishing.
>
There's a version 1.0 out by now.  That means stable as it's ever gonna get
:-)  I use it all the time, go for it!

  Issac


Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won\'t get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B






$r->args vs $r->content

2002-05-14 Thread Mike Melillo








 

 

 

Ok, I've switched to A::Request,
but it still seems my parameters table is empty.  I'll paste in the form data,
as well as some code snippets to see if that helps find the bug.

 

 

 

username

 

 

password



 



 



 

**End HTML Template**

 

** Join.pm **

 

sub submit {

    my $DEBUG = 1;

    my ($r) = shift;

    my $apr = Apache::Request->new($r);

    my $status = $apr->parse;

    my @param = $apr->param;

    $DEBUG &&
print STDERR Dumper($apr->parms)

    $DEBUG &&
print STDERR Dumper(@param);

 

...

}

 

 

The first Data::Dumper print
statement sends this to the errlog -> 

$VAR1 = bless( {}, 'Apache::Table'
);

 

The second print statement
prints nothing.

 

I looked at perldoc Apache::Request,
but didn’t see anything wrong...

 

Help?

 

Mike

 

 

 

-Original Message-

From: Issac Goldstand [mailto:[EMAIL PROTECTED]] 

Sent: Tuesday, May 14, 2002
4:39 AM

To: Mike Melillo

Cc: [EMAIL PROTECTED]

Subject: Re: $r->args vs
$r->content

 

Quoting Mike Melillo
<[EMAIL PROTECTED]>:

 

> 

> Hi,

> 

 

> One of the fields is an
image file that will be uploaded so I need to 

> use POST requests.  Is
this a job for Apache::Request?  The eagle book 

> doesn't cover it much
because it was "experimental" at the time of 

> publishing.

> 

There's a version 1.0 out by
now.  That means stable as it's ever gonna get :-)  I use it all the time, go
for it!

 

  Issac

 

 

Internet is a wonderful
mechanism for making a fool of

yourself in front of a very
large audience.

  --Anonymous

 

Moving the mouse won\'t get
you into trouble...  Clicking it might.

  --Anonymous

 

PGP Key 0xE0FA561B -
Fingerprint:

7E18 C018 D623 A57B 7F37
D902 8C84 7675 E0FA 561B

 

 








Re: $r->args vs $r->content

2002-05-14 Thread Issac Goldstand

Quoting Mike Melillo <[EMAIL PROTECTED]>:

> 
> Hi,
> 

> One of the fields is an image file that will be uploaded so I need to
> use POST requests.  Is this a job for Apache::Request?  The eagle book
> doesn't cover it much because it was "experimental" at the time of
> publishing.
> 
There's a version 1.0 out by now.  That means stable as it's ever gonna get :-)
 I use it all the time, go for it!

  Issac


Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won\'t get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B



RE: $r->args vs $r->content

2002-05-13 Thread Todd Finney

Yup, slight memory error when responding, sorry :)

$r->content is going to be empty if you're not using the 
application/x-www-form-urlencoded, perldoc Apache.

Page 131 of the Eagle book also says

"If the browser uses the newer multiport/form-data encoding (which is 
used for  file uploads, among other things), then mod_perl users will 
have to read and parse the content information themselves."

You need to use Apache::Request, or CGI.pm to do a file upload.  It's 
not going to work otherwise.   I've never had a problem with A::Request 
in production use; I don't think it's considered experimental any 
more.

cheers,
Todd

At 11:49 PM 5/13/02, Mike Melillo wrote:

>No, It specifies multipart/form-data because page 131 of the eagle 
>says
>its used for file uploads.
>
>Mike
>
>-Original Message-
>From: Todd Finney [mailto:[EMAIL PROTECTED]]
>Sent: Monday, May 13, 2002 11:16 PM
>To: [EMAIL PROTECTED]
>Subject: Re: $r->args vs $r->content
>
>At 10:29 PM 5/13/02, Mike Melillo wrote:
> >It works, but if I use the method in the eagle book for POST 
> requests
> >%params = $r->content; then nothing gets returned.  I've even 
> printed
> >%params to the apache errlog with DataDumper, and its empty.
> >
> >One of the fields is an image file that will be uploaded so I need 
> to
> >use POST requests.  Is this a job for Apache::Request?  The eagle 
> book
> >doesn't cover it much because it was "experimental" at the time of
> >publishing.
>
>Does your FORM tag specify enctype="application/x-www-urlencoded"?
>
>cheers,
>Todd




RE: $r->args vs $r->content

2002-05-13 Thread Mike Melillo


No, It specifies multipart/form-data because page 131 of the eagle says
its used for file uploads.

Mike 

-Original Message-
From: Todd Finney [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 13, 2002 11:16 PM
To: [EMAIL PROTECTED]
Subject: Re: $r->args vs $r->content

At 10:29 PM 5/13/02, Mike Melillo wrote:
>It works, but if I use the method in the eagle book for POST requests
>%params = $r->content; then nothing gets returned.  I've even printed
>%params to the apache errlog with DataDumper, and its empty.
>
>One of the fields is an image file that will be uploaded so I need to
>use POST requests.  Is this a job for Apache::Request?  The eagle book
>doesn't cover it much because it was "experimental" at the time of
>publishing.

Does your FORM tag specify enctype="application/x-www-urlencoded"?

cheers,
Todd




Re: $r->args vs $r->content

2002-05-13 Thread Todd Finney

At 10:29 PM 5/13/02, Mike Melillo wrote:
>It works, but if I use the method in the eagle book for POST requests
>%params = $r->content; then nothing gets returned.  I've even printed
>%params to the apache errlog with DataDumper, and its empty.
>
>One of the fields is an image file that will be uploaded so I need to
>use POST requests.  Is this a job for Apache::Request?  The eagle book
>doesn't cover it much because it was "experimental" at the time of
>publishing.

Does your FORM tag specify enctype="application/x-www-urlencoded"?

cheers,
Todd




$r->args vs $r->content

2002-05-13 Thread Mike Melillo


Hi,

I'm having issues processing user input via POST requests.  I have a
simple form page, that when you click submit I just want to redisplay
the page but with the values filled in. If I do a GET request and do
%params = $r->args;

It works, but if I use the method in the eagle book for POST requests
%params = $r->content; then nothing gets returned.  I've even printed
%params to the apache errlog with DataDumper, and its empty.  

One of the fields is an image file that will be uploaded so I need to
use POST requests.  Is this a job for Apache::Request?  The eagle book
doesn't cover it much because it was "experimental" at the time of
publishing.

Thanks,

Mike




[BUG?] CGI::Cookie->parse() deletes $r->content()

2001-04-04 Thread Michael Lazzaro


I'm looking to see if anyone can verify whether the following behavior is a 
Feature or a Bug.  From within a PerlRequestHandler:

my $content = $r->content();
my $cookie = CGI::Cookie->parse( $r->headers_in->get('Cookie') );

works fine, but the reversed code:

my $cookie = CGI::Cookie->parse( $r->headers_in->get('Cookie') );
my $content = $r->content();

... sets $content to undef.  I'm aware you can only call $r->content() 
once; but it seems odd that Cookie->parse would squish it too.(?)  Note 
that this code:

my $cookie = $r->headers_in->get('Cookie');
my $content = $r->content();
my $cookie_parsed = CGI::Cookie->parse( $cookie );

... is OK, implying it's the ->parse() that's undef'ing $content, not the 
call to headers_in().

-- using
(Apache/1.3.19 (Unix) mod_perl/1.25 Perl5.6.0 CGI::Cookie/1.12) undef Red 
Hat i686-linux:
-- the behavior doesn't happen on similarly configured older system,
(Apache/1.3.12 mod_perl/1.24 Perl5.005_03 CGI::Cookie/1.06))

Anyone else see this / can verify?

MikeL