Loading ...
Sorry, an error occurred while loading the content.

Cannot set content-type different from text/html

Expand Messages
  • Artem Koutchine
    I have tried everything i knew and still cannot set any content-type different from text/html here is the code: package Exec; use Apache::Constants qw(OK); use
    Message 1 of 6 , Mar 3, 2004
    • 0 Attachment
      I have tried everything i knew and still cannot
      set any content-type different from text/html

      here is the code:

      package Exec;
      use Apache::Constants qw(OK);
      use strict;
      sub handler {
      # Get the Apache request object...
      my $r = shift;
      # tried this
      #$r->content_type('text/plain');
      # tried and this
      #$r->header_out('Content-type:', 'text/plain');
      $r->send_http_header('text/plain');
      $r->print("<B>HELLO WORLD</B>\n");
      return OK;
      }

      1;

      virtual host config:

      <VirtualHost 212.248.52.90>
      ServerAdmin support@...
      ServerName cornertd.dev.itlegion.ru

      AddDefaultCharset windows-1251

      DocumentRoot "/hosts/cornertd.ru/htdata"

      ErrorLog /hosts/cornertd.ru/logs/errors
      CustomLog /hosts/cornertd.ru/logs/access combined

      AddHandler server-parsed .html

      <Directory "/hosts/cornertd.ru/htdata">
      Options Indexes +Includes FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
      </Directory>

      ScriptAlias /cgi-bin/ "/hosts/cornertd.ru/cgi-bin/"

      <Directory "/hosts/cornertd.ru/cgi-bin">
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
      </Directory>

      PerlWarn Off
      PerlModule Apache::DBI
      # tried on and off here
      # PerlSendHeader off
      <Location "/Go">
      SetHandler perl-script
      PerlHandler Camelia::Exec::Retail
      PerlSetEnv PERL5LIB "/hosts/cornertd.ru/cgi-bin/lib"
      # tried on and off
      PerlSendHeader off
      </Location>
      </VirtualHost>


      ------ TEST ---------
      osiris:hosts-> telnet osiris.itlegion.ru 80
      Trying 212.248.52.90...
      Connected to osiris.itlegion.ru.
      Escape character is '^]'.
      GET / HTTP/1.1
      Host: cornertd.dev.itlegion.ru

      HTTP/1.1 200 OK
      Date: Wed, 03 Mar 2004 12:40:41 GMT
      Server: Apache/1.3.27 (Unix) mod_fastcgi/2.4.0 mod_perl/1.27 PHP/4.3.4RC1
      mod_ssl/2.8.12 OpenSSL/0.9.7 AuthMySQL/2.20 mod_gzip/1.3.26.1a
      Transfer-Encoding: chunked
      Content-Type: text/html; charset=windows-1251

      14
      <B>HELLO WORLD</B>


      0

      As you see Content-Type: text/html; charset=windows-1251 and not text/plain
      which i have
      specified. (14 and 0 and due to the chuncked, i guess).

      Any ideas how to set text/plain ?

      Regards,
      Artem Kuchin
      General Director of IT Legion Ltd.
      Russia, Moscow
      www.itlegion.ru
      matrix@...
      +7 095 232-0338


      --
      Report problems: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
      List etiquette: http://perl.apache.org/maillist/email-etiquette.html
    • Stas Bekman
      ... [...] ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could this be the reason? Doesn t it apply only for text/html content types? ...
      Message 2 of 6 , Mar 3, 2004
      • 0 Attachment
        Artem Koutchine wrote:
        > I have tried everything i knew and still cannot
        > set any content-type different from text/html
        >
        > here is the code:
        >
        > package Exec;
        > use Apache::Constants qw(OK);
        > use strict;
        > sub handler {
        > # Get the Apache request object...
        > my $r = shift;
        > # tried this
        > #$r->content_type('text/plain');
        > # tried and this
        > #$r->header_out('Content-type:', 'text/plain');
        > $r->send_http_header('text/plain');
        > $r->print("<B>HELLO WORLD</B>\n");
        > return OK;
        > }
        [...]
        > AddDefaultCharset windows-1251
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        Could this be the reason? Doesn't it apply only for text/html content types?

        > GET / HTTP/1.1
        > Host: cornertd.dev.itlegion.ru
        >
        > HTTP/1.1 200 OK
        > Date: Wed, 03 Mar 2004 12:40:41 GMT
        > Server: Apache/1.3.27 (Unix) mod_fastcgi/2.4.0 mod_perl/1.27 PHP/4.3.4RC1
        > mod_ssl/2.8.12 OpenSSL/0.9.7 AuthMySQL/2.20 mod_gzip/1.3.26.1a
        > Transfer-Encoding: chunked
        > Content-Type: text/html; charset=windows-1251


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

        --
        Report problems: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
        List etiquette: http://perl.apache.org/maillist/email-etiquette.html
      • Geoffrey Young
        ... it will add a charset for text/html or text/plain. unrecognized types fall through unaltered. ... I think the problem is here - you don t have any mod_perl
        Message 3 of 6 , Mar 3, 2004
        • 0 Attachment
          >> AddDefaultCharset windows-1251
          >
          > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          > Could this be the reason? Doesn't it apply only for text/html content
          > types?

          it will add a charset for text/html or text/plain. unrecognized types fall
          through unaltered.

          >
          >> GET / HTTP/1.1
          >> Host: cornertd.dev.itlegion.ru

          I think the problem is here - you don't have any mod_perl handlers set up
          for / - mod_include is probably handling this request.

          AddHandler server-parsed .html

          <Location "/Go">
          SetHandler perl-script
          PerlHandler Camelia::Exec::Retail
          PerlSetEnv PERL5LIB "/hosts/cornertd.ru/cgi-bin/lib"
          # tried on and off
          PerlSendHeader off
          </Location>

          --Geoff


          --
          Report problems: http://perl.apache.org/bugs/
          Mail list info: http://perl.apache.org/maillist/modperl.html
          List etiquette: http://perl.apache.org/maillist/email-etiquette.html
        • Artem Koutchine
          ... Yes, that actually was the problem. When i do GET /Go HTTP/1.1 i get correct conetnt-type. But now i am totaly lost on how to configure apache to do what I
          Message 4 of 6 , Mar 3, 2004
          • 0 Attachment
            > I think the problem is here - you don't have any mod_perl handlers set up
            > for / - mod_include is probably handling this request.
            >
            > AddHandler server-parsed .html
            >
            > <Location "/Go">
            > SetHandler perl-script
            > PerlHandler Camelia::Exec::Retail
            > PerlSetEnv PERL5LIB "/hosts/cornertd.ru/cgi-bin/lib"
            > # tried on and off
            > PerlSendHeader off
            > </Location>
            >
            > --Geoff

            Yes, that actually was the problem. When i do
            GET /Go HTTP/1.1
            i get correct conetnt-type. But now i am totaly lost on how
            to configure apache to do what I want it to do.

            Here is what I need Apache to do:

            URL /cgi-bin/* must execute plain cgi scripts (no mod-perl)
            example: /cgi-bin/download

            URL /Go must run mod_perl handler
            example: /Go/ProductList/cid=3

            URL /static and /images must get the static files from some directories
            (*.jpg, *.gif, ..etc)
            example: /static/about.html
            example: /images/logo.gif

            ALL OTHER URLS (/....) must go to the mode_perl handler
            example: /ProductList/cid=3
            example: /click

            Any idea how to configure apache to do it?

            Regards,
            Artem


            --
            Report problems: http://perl.apache.org/bugs/
            Mail list info: http://perl.apache.org/maillist/modperl.html
            List etiquette: http://perl.apache.org/maillist/email-etiquette.html
          • Mike P. Mikhailov
            Hello Artem Koutchine, Wednesday, March 3, 2004, 5:46:12 PM, you wrote: AK PerlWarn Off AK PerlModule Apache::DBI AK # tried on and off here AK
            Message 5 of 6 , Mar 3, 2004
            • 0 Attachment
              Hello Artem Koutchine,

              Wednesday, March 3, 2004, 5:46:12 PM, you wrote:

              AK> PerlWarn Off
              AK> PerlModule Apache::DBI
              AK> # tried on and off here
              AK> # PerlSendHeader off
              AK> <Location "/Go">
              ^^^
              AK> SetHandler perl-script
              AK> PerlHandler Camelia::Exec::Retail
              AK> PerlSetEnv PERL5LIB "/hosts/cornertd.ru/cgi-bin/lib"
              AK> # tried on and off
              AK> PerlSendHeader off
              AK> </Location>
              AK> </VirtualHost>


              AK> ------ TEST ---------
              osiris:hosts->> telnet osiris.itlegion.ru 80
              AK> Trying 212.248.52.90...
              AK> Connected to osiris.itlegion.ru.
              AK> Escape character is '^]'.
              AK> GET / HTTP/1.1
              AK> Host: cornertd.dev.itlegion.ru

              Try 'GET /Go HTTP/1.1' instead. What you see ?

              --
              WBR, Mike P. Mikhailov

              mailto: mike@...
              ICQ: 280990142

              The first human who hurled an insult instead of a stone was the founder of civilization.


              --
              Report problems: http://perl.apache.org/bugs/
              Mail list info: http://perl.apache.org/maillist/modperl.html
              List etiquette: http://perl.apache.org/maillist/email-etiquette.html
            • Geoffrey Young
              ... are you 100% sure about that. it s probably really not what you want, but only you know your application. but ok, you can do that by setting up
              Message 6 of 6 , Mar 4, 2004
              • 0 Attachment
                > ALL OTHER URLS (/....) must go to the mode_perl handler

                are you 100% sure about that. it's probably really not what you want, but
                only you know your application.

                but ok, you can do that by setting up

                <Location />
                your mod_perl stuff
                </Location>

                HTH

                --Geoff


                --
                Report problems: http://perl.apache.org/bugs/
                Mail list info: http://perl.apache.org/maillist/modperl.html
                List etiquette: http://perl.apache.org/maillist/email-etiquette.html
              Your message has been successfully submitted and would be delivered to recipients shortly.