You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Nick Tonkin <ni...@tonkinresolutions.com> on 2003/02/20 11:27:52 UTC

[mp2] porting tip - DefaultType text/html

As the docs say $r->send_http_header is deprecated because it is unneeded
in mp2 ... but $r->content_type must be set.

DefaultType is set by default to text/plain in httpd.conf, so browsers
that strictly apply content_type (eg Opera 7) were showing the content as
HTML source.

I had several handlers that simply called $r->send_http_header so
replacing each occurence with $r->content_type wasn't much of an
improvement in code cleanliness and simplicity, if that's what the goal of
eliminating send_http_headers was in the first place.

Therefore, I changed DefaultType from text/plain to text/html and voila --
I don't have to set $r->content_type after all but rather can just delete
all the $r->send_http_headers calls.

YMMV, of course, if you have other parts of your webserver that do not
supply a content-type :)

- nick

-- 

~~~~~~~~~~~~~~~~~~~~
Nick Tonkin   {|8^)>


Re: [mp2] porting tip - DefaultType text/html

Posted by Stas Bekman <st...@stason.org>.
Nick Tonkin wrote:
> As the docs say $r->send_http_header is deprecated because it is unneeded
> in mp2 ... but $r->content_type must be set.

Just a minor nit: $r->send_http_header is *not* deprecated, it's *gone*. Since 
yesterday for it's gone for real and is only available only in the back 
compatibility layer Apache::compat. So if you choose to use Apache::compat you 
can keep it, if you don't use Apache::compat you have to remove it.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com