Re: missing POST data but not GET.....

2008-05-23 Thread Tracy12

I removed the mp1 codes,

Also used Apache2 cookie,  but still the post data is not there but still I
am using CGI session.
Should I use some other session handling...

How can I make sure that my $r is a Apache2 request.

Do I have to do as follows and use $req for all the references e.g setting
remote user variables etc
 my $req = Apache2::Request-new($r, POST_MAX = 1M);

waiting for a quick reply. pls advice

I have the following use statements and not refering to any mp1 code

use CGI;
use CGI::Session;

use Apache2::ServerUtil;
use Apache2::Request;
use Apache2::URI;
use Apache2::Cookie;
use Apache2::Log;
use APR::URI ; 









Joe Schaefer-6 wrote:
 
 
 --- Rob French [EMAIL PROTECTED] wrote:
 
 Hi,
 
 POST data is read directly from the socket and can
 only be read once.
 
 No.  POST data is read through httpd's filter api.
 How many times you can read it depends on what's in
 the input filter chain.
 
 The original poster should be using apreq
 (APR::Request::Apache2 or Apache2::Request)
 for this, not some other perl module that doesn't
 exploit the filter api.
 
 
 
   
 
 

-- 
View this message in context: 
http://www.nabble.com/missing-POST-data-but-not-GET.-tp17222133p17419769.html
Sent from the mod_perl - General mailing list archive at Nabble.com.



Apache2::Request

2008-05-23 Thread mome

Hi,

I am trying to use mod_perl2 with Apache2::Request. My intention is to get
parameter value of post method. As described in its document and previouse
threads said to cache the data with post method...
Use Apache2::Request in the auth handler, and apreq
will do the SOMETHING you need automatically.

My existing code i.e. handler  begins with 
sub my_handler {
  my $self = shift;
  my $r = shift; 
   
...
 I guess that  $r refers to  Apache2::RequestRec object because the lines
that follows use methods of this object.

With the little knowledge, I don't know why calling $r = shift returns
Apache2::RequestRec.
How can I make use Apache2::Request in my handler so I can preseve the
parameter via post method?

I tried the following line without success

sub my_handler {
  my $self = shift;
  my $r = shift; 
  my $req = Apache2::Request-new($r, POST_MAX = 1M);
...
...
}
Please advice.

PA


  







-- 
View this message in context: 
http://www.nabble.com/Apache2%3A%3ARequest-tp17420698p17420698.html
Sent from the mod_perl - General mailing list archive at Nabble.com.



Bug: Character sets and $r-custom_response

2008-05-23 Thread Clinton Gormley
Hi all

There seems to be a bug in the mod_perl2/apache2 handling of character
sets for $r-custom_response().  I'm not sure which is at fault.

My pages are all in UTF8, but I can't find a way to set this character
set for custom generated error pages.

I've tried:

 - $r-content_type('text/html; charset = utf8');
 - $r-err_headers_out('Content-type' ='text/html; charset = utf8');
 - meta http-equiv = Content-Type content = text/html; charset=utf-8 /
 - AddDefaultCharset UTF8

to no avail - apache always overrides this with:

   Content-Type: text/html; charset=iso-8859-1

According to the apache docs for AddDefaultCharset:

Note: This will not have any effect on the Content-Type and
character set for default Apache-generated status pages (such as
'404 Not Found' or '301 Moved Permanently') because those have
an actual character set (that in which the hard-coded page
content is written) and don't need to have a default applied.

That implies that the character set is taken from the file itself, but
that shouldn't apply to errors generated with
$r-custom_response($error_msg)

For now, I plan to just entity escape anything that isn't in the ASCII
range, but is there a workaround? Should this be fixed?

thanks

Clint



Re: Bug: Character sets and $r-custom_response

2008-05-23 Thread Clinton Gormley

 For now, I plan to just entity escape anything that isn't in the ASCII
 range, but is there a workaround? Should this be fixed?

For those looking for an easy workaround for this, this is what I've
used:

   $output = Encode::encode('iso-8859-1',$output,Encode::FB_HTMLCREF);

To explain:

 - $output contains the full HTML page that I'm passing to 
   $r-custom_response

 - This, of course, includes   characters, so you don't want to do
   a straight encode_entities

 - So the above command tries to convert the string to ISO-8859-1

 - The last argument tells encode that, when it finds a character that 
   it can't represent in ISO-8859-1, it should replace it with the
   relevant HTML entity.


Clint



Re: Current working directory always /

2008-05-23 Thread Perrin Harkins
On Thu, May 22, 2008 at 11:37 PM, Foo JH [EMAIL PROTECTED] wrote:
 To conclude, I can't agree with your statement
 that people don't use threads.

I disagree with that statement too.  What I actually said was that
most people don't use threads (since they are on Linux) and that
people who don't use threads don't need to worry about them when
writing internal code they don't plan to distribute.  Of course Win32
users will run threads and will need to write all of their code with
threads in mind.

- Perrin


Re: Apache2::Request

2008-05-23 Thread xyon
Shouldn't it be:

 sub my_handler {
   my $r = shift;
   my $req = Apache2::Request-new($r, POST_MAX = 1M);
...


On Friday 23 May 2008 04:49:55 mome wrote:
 Hi,

 I am trying to use mod_perl2 with Apache2::Request. My intention is to get
 parameter value of post method. As described in its document and previouse
 threads said to cache the data with post method...
 Use Apache2::Request in the auth handler, and apreq
 will do the SOMETHING you need automatically.

 My existing code i.e. handler  begins with
 sub my_handler {
   my $self = shift;
   my $r = shift;
 
 ...
  I guess that  $r refers to  Apache2::RequestRec object because the lines
 that follows use methods of this object.

 With the little knowledge, I don't know why calling $r = shift returns
 Apache2::RequestRec.
 How can I make use Apache2::Request in my handler so I can preseve the
 parameter via post method?

 I tried the following line without success

 sub my_handler {
   my $self = shift;
   my $r = shift;
   my $req = Apache2::Request-new($r, POST_MAX = 1M);
 ...
 ...
 }
 Please advice.

 PA



-- 

xyon


Re: Bug: Character sets and $r-custom_response

2008-05-23 Thread Geoffrey Young



Clinton Gormley wrote:

Hi all

There seems to be a bug in the mod_perl2/apache2 handling of character
sets for $r-custom_response().  I'm not sure which is at fault.

My pages are all in UTF8, but I can't find a way to set this character
set for custom generated error pages.

I've tried:

 - $r-content_type('text/html; charset = utf8');
 - $r-err_headers_out('Content-type' ='text/html; charset = utf8');
 - meta http-equiv = Content-Type content = text/html; charset=utf-8 /
 - AddDefaultCharset UTF8

to no avail - apache always overrides this with:

   Content-Type: text/html; charset=iso-8859-1

According to the apache docs for AddDefaultCharset:

Note: This will not have any effect on the Content-Type and
character set for default Apache-generated status pages (such as
'404 Not Found' or '301 Moved Permanently') because those have
an actual character set (that in which the hard-coded page
content is written) and don't need to have a default applied.

That implies that the character set is taken from the file itself, but
that shouldn't apply to errors generated with
$r-custom_response($error_msg)

For now, I plan to just entity escape anything that isn't in the ASCII
range, but is there a workaround? Should this be fixed?


this isn't a mod_perl thing, it's an httpd thing. this is from 1.3:

  http://www.mail-archive.com/[EMAIL PROTECTED]/msg20549.html

it seems the same holds true in httpd 2.0, it seems.  see 
ap_send_error_response in


  modules/http/http_protocol.c

try setting subprocess_env(suppress-error-charset = 1) and see if that 
helps you at all.


--Geoff


Re: Bug: Character sets and $r-custom_response

2008-05-23 Thread Clinton Gormley

 this isn't a mod_perl thing, it's an httpd thing. this is from 1.3:
 
http://www.mail-archive.com/[EMAIL PROTECTED]/msg20549.html
 
 it seems the same holds true in httpd 2.0, it seems.  see 
 ap_send_error_response in
 
modules/http/http_protocol.c
 
 try setting subprocess_env(suppress-error-charset = 1) and see if that 
 helps you at all.

Hah! That does indeed work.  Well, it doesn't honour my utf8 setting,
but it just sends no character set.

Rather than that, I'm going to keep the explicit character set with the
entity escaping - at least that way the result should be consistent.

thanks for the help Geoff

Clint



Re: Apache2::Request

2008-05-23 Thread adam . prime

Quoting xyon [EMAIL PROTECTED]:


Shouldn't it be:

 sub my_handler {
   my $r = shift;
   my $req = Apache2::Request-new($r, POST_MAX = 1M);
...



Provided that you've actually installed libapreq  
(http://httpd.apache.org/apreq/), that should work.




Re: Apache2::Request

2008-05-23 Thread Perrin Harkins
On Fri, May 23, 2008 at 4:49 AM, mome [EMAIL PROTECTED] wrote:
 I tried the following line without success

 sub my_handler {
  my $self = shift;
  my $r = shift;
  my $req = Apache2::Request-new($r, POST_MAX = 1M);

You only want that additional shift at the beginning if you are
calling your handler as a method.  You probably aren't, since you
don't have a method sub attribute here.  That means that the request
object ($r) will be the first thing passed, not the second.  There is
no $self when calling handlers as subs.

- Perrin


Re: Apache2::Request

2008-05-23 Thread John Drago

--- [EMAIL PROTECTED] wrote:

 Quoting xyon [EMAIL PROTECTED]:
 
  Shouldn't it be:
 
   sub my_handler {
 my $r = shift;
 my $req = Apache2::Request-new($r, POST_MAX =
 1M);
  ...
 
 
 Provided that you've actually installed libapreq  
 (http://httpd.apache.org/apreq/), that should work.
 
 


Your mod_perl handler is passed either 1 or 2
parameters, depending on how you declare your method.

Example:

sub handler {
  my ($r) = @_;
}


sub handler : method {
  my ($class, $r) = @_;
}

In either case, $r is an Apache2::RequestRec.  The
difference is the : method attribute that tells
mod_perl to pass your handler sub 2 parameters
instead of just 1.

- John Drago
http://www.devstack.com
http://search.cpan.org/dist/Apache2-ASP