Re: [Problem] Can't return Content-type with SERVER_ERROR

2001-07-30 Thread Paul Kulchenko

Hi, Stas!

 i think you want to use err_headers_out() instead.

http://www.modperl.com/book/chapters/ch9.html#Server_Response_Methods

Thanks for the help, but it seems like I'm using it already:

$self-response-headers-scan(sub { $r-err_header_out(@_) });
# ---^^
$r-content_type(join '; ', $self-response-content_type);
$r-custom_response($self-response-code,
$self-response-content);

it's the same as to use err_headers_out as far as I understand. What
is the general procedure to generate custom content-type along with
SERVER_ERROR?

sub handler {
  ...
  $r-content_type('text/xml; charset=utf-8');
  $r-custom_response($self-response-code,
  $self-response-content);
  $self-response-code;
}

doesn't work if '$self-response-code' is 500. mod_perl overrides my
content-type with text/html.

Best wishes, Paul.

--- Stas Bekman [EMAIL PROTECTED] wrote:
 On Sun, 29 Jul 2001, Paul Kulchenko wrote:
 
  Hi, All!
 
  Code is simple, but I can't return custom content-type with
  SERVER_ERROR:
 
  sub handler {
 
. $self-response is HTTP::Response object
 
if ($self-response-is_success) {
  $self-response-headers-scan(sub { $r-header_out(@_) });
  $r-send_http_header(join '; ',
 $self-response-content_type);
  $r-print($self-response-content);
} else {
  $self-response-headers-scan(sub { $r-err_header_out(@_)
 });
  $r-content_type(join '; ', $self-response-content_type);
  $r-custom_response($self-response-code,
  $self-response-content);
}
$self-response-code;
  }
 
 i think you want to use err_headers_out() instead.

http://www.modperl.com/book/chapters/ch9.html#Server_Response_Methods
 
  In ALL cases (200OK and 500ServerError) I need to return error
 code,
  content, content-type and optional headers.
 
  Regardless of my settings content-type is always text/html;
  charset=iso-8859-1 which I expect to be text/xml;
 charset=utf-8:
 
  HTTP/1.1 500 Internal Server Error
  Connection: close
  Date: Sun, 29 Jul 2001 16:01:20 GMT
  Server: Apache/1.3.12 (Win32) mod_perl/1.23
  Content-Length: 642
  Content-Type: text/html; charset=iso-8859-1
  Client-Date: Sun, 29 Jul 2001 16:01:22 GMT
  Client-Peer: 127.0.0.1:80
  SOAPServer: SOAP::Lite/Perl/0.51
 
  ?xml version=1.0 encoding=UTF-8?SOAP-ENV:Envelope
  xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/;
 
 SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/;
  xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/;
  xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance;
 

xmlns:xsd=http://www.w3.org/1999/XMLSchema;SOAP-ENV:BodySOAP-ENV:Faultfaultcode
  xsi:type=xsd:stringSOAP-ENV:Client/faultcodefaultstring
  xsi:type=xsd:stringFailed to locate method (echo1) in class
  (My::Parameters) at C:/Perl/site/5.6.0/lib/SOAP/Lite.pm line
 1997.
 
 /faultstring/SOAP-ENV:Fault/SOAP-ENV:Body/SOAP-ENV:Envelope
 
  What am I doing wrong and what is the correct way to specify
 custom
  content-type? Everything works fine with 200OK. Thanks a lot.
 
  Best wishes, Paul.
 
  __
  Do You Yahoo!?
  Make international calls for as low as $.04/minute with Yahoo!
 Messenger
  http://phonecard.yahoo.com/
 
 
 
 

_
 Stas Bekman  JAm_pH --   Just Another mod_perl
 Hacker
 http://stason.org/   mod_perl Guide 
 http://perl.apache.org/guide
 mailto:[EMAIL PROTECTED]   http://apachetoday.com
 http://eXtropia.com/
 http://singlesheaven.com http://perl.apache.org
 http://perlmonth.com/
 
 


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



RE: [Problem] Can't return Content-type with SERVER_ERROR

2001-07-30 Thread Geoffrey Young



 -Original Message-
 From: Paul Kulchenko [mailto:[EMAIL PROTECTED]]
 Sent: Monday, July 30, 2001 2:53 AM
 To: Stas Bekman
 Cc: [EMAIL PROTECTED]
 Subject: Re: [Problem] Can't return Content-type with SERVER_ERROR
 

[snip]

 
 it's the same as to use err_headers_out as far as I understand. What
 is the general procedure to generate custom content-type along with
 SERVER_ERROR?
 
 sub handler {
   ...
   $r-content_type('text/xml; charset=utf-8');
   $r-custom_response($self-response-code,
   $self-response-content);
   $self-response-code;
 }
 
 doesn't work if '$self-response-code' is 500. mod_perl overrides my
 content-type with text/html.
 

your procedure is correct.  well, except that you can't do what you want :)

take a look at http_protocol.c - 

'r-content_type = text/html; charset=iso-8859-1;' is hardcoded in
ap_send_error_response(), so it's an apache thing and not a mod_perl
thing...

HTH

--Geoff
 



RE: [Problem] Can't return Content-type with SERVER_ERROR

2001-07-30 Thread Paul Kulchenko

Hi, Geoffrey!

 your procedure is correct.  well, except that you can't do what you
 want :)
 
 take a look at http_protocol.c - 
 
 'r-content_type = text/html; charset=iso-8859-1;' is hardcoded
 in ap_send_error_response(), so it's an apache thing and not a
 mod_perl thing...
Absolutely true to my surprise. That means you can't return proper
content-type and content-encoding with non-OK codes, Apache will
rewrite it for you anyway, which is too human-oriented and imho
should be corrected. I ended up generating usual successful response
with custom status (which is 500 in my case):

  $r-status($self-response-code);
  $self-response-headers-scan(sub { $r-header_out(@_) });
  $r-send_http_header(join '; ', $self-response-content_type);
  $r-print($self-response-content);
  Apache::Constants::OK;

Probably worth mentioning in FAQ or somewhere. It took quite a bit of
my time.

Best wishes, Paul.

--- Geoffrey Young [EMAIL PROTECTED] wrote:
 
 
  -Original Message-
  From: Paul Kulchenko [mailto:[EMAIL PROTECTED]]
  Sent: Monday, July 30, 2001 2:53 AM
  To: Stas Bekman
  Cc: [EMAIL PROTECTED]
  Subject: Re: [Problem] Can't return Content-type with
 SERVER_ERROR
  
 
 [snip]
 
  
  it's the same as to use err_headers_out as far as I understand.
 What
  is the general procedure to generate custom content-type along
 with
  SERVER_ERROR?
  
  sub handler {
...
$r-content_type('text/xml; charset=utf-8');
$r-custom_response($self-response-code,
$self-response-content);
$self-response-code;
  }
  
  doesn't work if '$self-response-code' is 500. mod_perl
 overrides my
  content-type with text/html.
  
 
 your procedure is correct.  well, except that you can't do what you
 want :)
 
 take a look at http_protocol.c - 
 
 'r-content_type = text/html; charset=iso-8859-1;' is hardcoded
 in
 ap_send_error_response(), so it's an apache thing and not a
 mod_perl
 thing...
 
 HTH
 
 --Geoff
  


__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/



RE: [Problem] Can't return Content-type with SERVER_ERROR

2001-07-30 Thread Stas Bekman

On Mon, 30 Jul 2001, Paul Kulchenko wrote:

 Hi, Geoffrey!

  your procedure is correct.  well, except that you can't do what you
  want :)
 
  take a look at http_protocol.c -
 
  'r-content_type = text/html; charset=iso-8859-1;' is hardcoded
  in ap_send_error_response(), so it's an apache thing and not a
  mod_perl thing...
 Absolutely true to my surprise. That means you can't return proper
 content-type and content-encoding with non-OK codes, Apache will
 rewrite it for you anyway, which is too human-oriented and imho
 should be corrected. I ended up generating usual successful response
 with custom status (which is 500 in my case):

   $r-status($self-response-code);
   $self-response-headers-scan(sub { $r-header_out(@_) });
   $r-send_http_header(join '; ', $self-response-content_type);
   $r-print($self-response-content);
   Apache::Constants::OK;

 Probably worth mentioning in FAQ or somewhere. It took quite a bit of
 my time.

I've added it to the guide.

 Best wishes, Paul.


_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/





Re: [Problem] Can't return Content-type with SERVER_ERROR

2001-07-29 Thread Stas Bekman

On Sun, 29 Jul 2001, Paul Kulchenko wrote:

 Hi, All!

 Code is simple, but I can't return custom content-type with
 SERVER_ERROR:

 sub handler {

   . $self-response is HTTP::Response object

   if ($self-response-is_success) {
 $self-response-headers-scan(sub { $r-header_out(@_) });
 $r-send_http_header(join '; ', $self-response-content_type);
 $r-print($self-response-content);
   } else {
 $self-response-headers-scan(sub { $r-err_header_out(@_) });
 $r-content_type(join '; ', $self-response-content_type);
 $r-custom_response($self-response-code,
 $self-response-content);
   }
   $self-response-code;
 }

i think you want to use err_headers_out() instead.
http://www.modperl.com/book/chapters/ch9.html#Server_Response_Methods

 In ALL cases (200OK and 500ServerError) I need to return error code,
 content, content-type and optional headers.

 Regardless of my settings content-type is always text/html;
 charset=iso-8859-1 which I expect to be text/xml; charset=utf-8:

 HTTP/1.1 500 Internal Server Error
 Connection: close
 Date: Sun, 29 Jul 2001 16:01:20 GMT
 Server: Apache/1.3.12 (Win32) mod_perl/1.23
 Content-Length: 642
 Content-Type: text/html; charset=iso-8859-1
 Client-Date: Sun, 29 Jul 2001 16:01:22 GMT
 Client-Peer: 127.0.0.1:80
 SOAPServer: SOAP::Lite/Perl/0.51

 ?xml version=1.0 encoding=UTF-8?SOAP-ENV:Envelope
 xmlns:SOAP-ENC=http://schemas.xmlsoap.org/soap/encoding/;
 SOAP-ENV:encodingStyle=http://schemas.xmlsoap.org/soap/encoding/;
 xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/;
 xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance;
 
xmlns:xsd=http://www.w3.org/1999/XMLSchema;SOAP-ENV:BodySOAP-ENV:Faultfaultcode
 xsi:type=xsd:stringSOAP-ENV:Client/faultcodefaultstring
 xsi:type=xsd:stringFailed to locate method (echo1) in class
 (My::Parameters) at C:/Perl/site/5.6.0/lib/SOAP/Lite.pm line 1997.
 /faultstring/SOAP-ENV:Fault/SOAP-ENV:Body/SOAP-ENV:Envelope

 What am I doing wrong and what is the correct way to specify custom
 content-type? Everything works fine with 200OK. Thanks a lot.

 Best wishes, Paul.

 __
 Do You Yahoo!?
 Make international calls for as low as $.04/minute with Yahoo! Messenger
 http://phonecard.yahoo.com/




_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]   http://apachetoday.com http://eXtropia.com/
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/