"Evaldas Imbrasas" <[EMAIL PROTECTED]> wrote:
> It's probably CGI.pm problem, but since it's used by CGI::Application, I
> thought I will address this issue.
>
> ...By default, CGI.pm appends 'Content-Type:
> text/html\n\n' to the output before sending it to the browser, which is
> fine. That was for version 2.56 of CGI.pm. Higher versions seem to
> produce 'Content-Type: text/html; charset=\n\n' header instead. Which
> would probably be fine for the usual webserver. Our apache, however is
> extended to add custom headers and footers to each page or script, and
> this header breaks it - no custom headers and footers are added.
footers? i've seen lots of apache (especially mod_perl) extensions that
generate HTTP headers, but footers?
> Question: how can I turn this 'Content-Type: text/html; charset=\n\n'
> thing off and use good old 'Content-Type: text/html\n\n' instead? As I
> understand, even though it is a CGI.pm thing, I should be able to turn
> it off somewhere in my script that actually uses CGI::Application.
well, CGI.pm (and thus, CGI::Application) pretty much takes over your
low-level http transaction, so it may very well break certain custom server
modifications. on the other hand, both CGI.pm and CGI::Application are
heavily used and regularly tested by real users to be compatible with as
many Apache and mod_perl configurations as, well, users use, and submit bug
reports about. are your server extensions publicly available? if so i'm
sure there is a way to set the header in such a way that CGI.pm (or
mod_perl's Apache::Request objects which is very similar to CGI.pm's query
object) knows about it, respects it and so is compatible with it. but aside
from that, yes this would be a CGI.pm issue more than a CGI Application one.
so, according to the CGI.pm docs, you *can* get (or set) the charset that
CGI.pm sends by calling the the CGI.pm object's ->charset() method (which
CGI::Application exposes via the ->query method). so if your application
"knows" that the html it's returning is encoded in a specific character set,
you can have CGI.pm respect that by doing something like (for instance):
sub runmmode {
my $self=shift;
$self->query->charset('shift-jis');
return $encoded_stuff;
}
and it would produce the "complete" content-type header even if that's
somewhat redunandant or inelegant in your situation. the "old" style header
without the charset is also "correct" (and in your case apparently more
flexible, since Apache has already made this decision and set the header)
but the reason the charset is now (recommended to be) set as part of the
content-type header is that it's a MIME header, and there *could* be
multiple parts, each with different content-types and different charsets.
on the other hand, if the app doesn't know what charset apache set, i wonder
if calling the charset function above, and passing it an empty string or
undef would give you just the content-type part of the header that you're
looking for. have you tried that?
hth,
-dave
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]