You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joachim Zobel <jz...@heute-morgen.de> on 2012/04/29 10:45:41 UTC

Can I somehow call ap_make_content_type

Hi. 

Is it possible to access a function (ap_make_content_type) that is only
present in xs/tables/current/Apache2/FunctionTable.pm and
xs/maps/apache2_functions.map but not wrapped any further?

Writing a little piece of XS is doable, but I want to do it the mod_perl
way.

Thx,
Joachim


[Feature Request] Please wrap ap_make_content_type

Posted by Joachim Zobel <jz...@heute-morgen.de>.
Hi.

I have found that the content type header, that is sent is not the one
from $r->content_type. Instead it is
$r->make_content_type($r->content_type). This is (as far as I understand
it) because of the meaning of default (use, if no other is set).
make_content_type adds the default charset that has been set with
AddDefaultCharset directly before sending the header.

In some situations it is necessary to know the charset that would be
sent. I found this while tracking down a charset bug in my module
(Cindy::Apache2). This runs the libxml2 parser on the content returned
by a subrequest. To do this correctly it must know the charset, which in
a correctly configured apache is the charset that would be sent over the
net.
  
It should be easy to do.

As Torsten Foetsch said:
!MODULE=Apache2::HTTPCore
>ap_process_request
>ap_make_content_type
>ap_core_reorder_directories
>ap_index_of_response

It should be enough to change that to

MODULE=Apache2::HTTPCore   PACKAGE=Apache2::RequestRec
>ap_process_request
 ap_make_content_type
>ap_core_reorder_directories
>ap_index_of_response

Thanks,
Joachim



Re: Can I somehow call ap_make_content_type

Posted by Joachim Zobel <jz...@heute-morgen.de>.
Am Sonntag, den 29.04.2012, 14:31 +0200 schrieb Torsten Förtsch:
> It should be enough to change that to
> 
> MODULE=Apache2::HTTPCore   PACKAGE=Apache2::RequestRec
> >ap_process_request
>  ap_make_content_type
> >ap_core_reorder_directories
> >ap_index_of_response

Unfortunately changing mod_perl is not an option, I don't thing this is
an acceptable patch, is it? 

I need to do this to fix a bug in my cpan module Cindy-Apache2.

Is there another way? 

Thanks,
Joachim




Re: Can I somehow call ap_make_content_type

Posted by Joachim Zobel <jz...@heute-morgen.de>.
Hi.

It should be possible to add the generated HTTPCore.xs to my module and
that is it, right?

Thx,
Joachim



Re: Can I somehow call ap_make_content_type

Posted by Torsten Förtsch <to...@gmx.net>.
On Sunday, 29 April 2012 10:45:41 Joachim Zobel wrote:
> Is it possible to access a function (ap_make_content_type) that is only
> present in xs/tables/current/Apache2/FunctionTable.pm and
> xs/maps/apache2_functions.map but not wrapped any further?

!MODULE=Apache2::HTTPCore
>ap_process_request
>ap_make_content_type
>ap_core_reorder_directories
>ap_index_of_response

It should be enough to change that to

MODULE=Apache2::HTTPCore   PACKAGE=Apache2::RequestRec
>ap_process_request
 ap_make_content_type
>ap_core_reorder_directories
>ap_index_of_response

Then "perl Makefile.PL && make test"

This builds a new module Apache2::HTTPCore which implements one method:

  use Apache2::HTTPCore ();
  $newtype=$r->make_content_type($type);

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net