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

Re: mod_perl 2: APR::URI scheme and path_info

Expand Messages
  • Stas Bekman
    ... APR::URI- parse($r- pool, $r- uri)- scheme; ... $path_info = $r- path_info; $r- path_info($path_info);
    Message 1 of 15 , Oct 1, 2003
      Matisse Enzer wrote:
      > my $uri = APR::URI->parse;
      >
      > I want to find out what the scheme (http, https) was for the current
      > request.

      APR::URI->parse($r->pool, $r->uri)->scheme;

      > I also want to find out (and maybe set) the path_info
      >
      > What's the right way to do this?

      $path_info = $r->path_info;

      $r->path_info($path_info);


      __________________________________________________________________
      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
    • Matisse Enzer
      ... 1. Problem Description: I tried: my $scheme = APR::URI- parse($r- pool, $r- uri)- scheme; and it didn t seem to work. My server is on port 9000 but I got
      Message 2 of 15 , Oct 2, 2003
        -------------8<---------- Start Bug Report ------------8<----------
        1. Problem Description:

        I tried:
        my $scheme = APR::URI->parse($r->pool, $r->uri)->scheme;

        and it didn't seem to work. My server is on port 9000 but I got
        nothing in $scheme.



        At 4:53 PM -0700 10/1/03, Stas Bekman wrote:
        >Matisse Enzer wrote:
        >> my $uri = APR::URI->parse;
        >>
        >>I want to find out what the scheme (http, https) was for the current request.
        >
        >APR::URI->parse($r->pool, $r->uri)->scheme;
        >
        >>I also want to find out (and maybe set) the path_info
        >>
        >>What's the right way to do this?
        >
        >$path_info = $r->path_info;
        >
        >$r->path_info($path_info);



        2. Used Components and their Configuration:

        *** mod_perl version 1.9910

        *** using
        /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/Apache/BuildConfig.pm
        *** Makefile.PL options:
        MP_AP_PREFIX => /usr/local/apache2
        MP_COMPAT_1X => 1
        MP_GENERATE_XS => 1
        MP_LIBNAME => mod_perl
        MP_USE_DSO => 1
        MP_USE_STATIC => 1


        *** /usr/local/apache2/bin/httpd -V
        Server version: Apache/2.0.47
        Server built: Sep 24 2003 11:08:28
        Server's Module Magic Number: 20020903:4
        Architecture: 32-bit
        Server compiled with....
        -D APACHE_MPM_DIR="server/mpm/prefork"
        -D APR_HAS_SENDFILE
        -D APR_HAS_MMAP
        -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
        -D APR_USE_SYSVSEM_SERIALIZE
        -D APR_USE_PTHREAD_SERIALIZE
        -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
        -D APR_HAS_OTHER_CHILD
        -D AP_HAVE_RELIABLE_PIPED_LOGS
        -D HTTPD_ROOT="/usr/local/apache2"
        -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
        -D DEFAULT_PIDLOG="logs/httpd.pid"
        -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
        -D DEFAULT_LOCKFILE="logs/accept.lock"
        -D DEFAULT_ERRORLOG="logs/error_log"
        -D AP_TYPES_CONFIG_FILE="conf/mime.types"
        -D SERVER_CONFIG_FILE="conf/httpd.conf"


        *** /usr/bin/perl -V
        Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
        Platform:
        osname=linux, osvers=2.4.21-1.1931.2.382.entsmp,
        archname=i386-linux-thread-multi
        uname='linux str'
        config_args='-des -Doptimize=-O2 -g -pipe -march=i386 -mcpu=i686
        -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc
        -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr
        -Darchname=i386-linux -Dvendorprefix=/usr -Dsiteprefix=/usr
        -Dotherlibdirs=/usr/lib/perl5/5.8.0 -Duseshrplib -Dusethreads
        -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db
        -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio
        -Dinstallusrbinperl -Ubincompat5005 -Uversiononly
        -Dpager=/usr/bin/less -isr'
        hint=recommended, useposix=true, d_sigaction=define
        usethreads=define use5005threads=undef'
        useithreads=define usemultiplicity=
        useperlio= d_sfio=undef uselargefiles=define usesocks=undef
        use64bitint=undef use64bitall=un uselongdouble=
        usemymalloc=, bincompat5005=undef
        Compiler:
        cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE
        -DTHREADS_HAVE_PIDS -DDEBUGGING -fno-strict-aliasing
        -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
        -I/usr/include/gdbm',
        optimize='',
        cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS
        -DDEBUGGING -fno-strict-aliasing -I/usr/local/include
        -I/usr/include/gdbm'
        ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux
        3.2.2-5)', gccosandvers=''
        gccversion='3.2.2 200302'
        intsize=r, longsize=r, ptrsize=5, doublesize=8, byteorder=1234
        d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
        ivtype='long'
        k', ivsize=4'
        ivtype='l, nvtype='double'
        o_nonbl', nvsize=, Off_t='', lseeksize=8
        alignbytes=4, prototype=define
        Linker and Libraries:
        ld='gcc'
        l', ldflags =' -L/u'
        libpth=/usr/local/lib /lib /usr/lib
        libs=-lnsl -lgdbm -ldb -ldl -lm -lpthread -lc -lcrypt -lutil
        perllibs=
        libc=/lib/libc-2.3.2.so, so=so, useshrplib=true, libperl=libper
        gnulibc_version='2.3.2'
        Dynamic Linking:
        dlsrc=dl_dlopen.xs, dlext=so', d_dlsymun=undef,
        ccdlflags='-rdynamic
        -Wl,-rpath,/usr/lib/perl5/5.8.0/i386-linux-thread-multi/CORE'
        cccdlflags='-fPIC'
        ccdlflags='-rdynamic -Wl,-rpath,/usr/lib/perl5', lddlflags='s
        Unicode/Normalize XS/A'


        Characteristics of this binary (from libperl):
        Compile-time options: DEBUGGING MULTIPLICITY USE_ITHREADS
        USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
        Locally applied patches:
        MAINT18379
        Built under linux
        Compiled at Aug 13 2003 11:47:58
        %ENV:
        PERL_LWP_USE_HTTP_10="1"
        @INC:
        /usr/lib/perl5/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/5.8.0
        /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/site_perl/5.8.0
        /usr/lib/perl5/site_perl
        /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/vendor_perl/5.8.0
        /usr/lib/perl5/vendor_perl
        /usr/lib/perl5/5.8.0/i386-linux-thread-multi
        /usr/lib/perl5/5.8.0
        .

        3. This is the core dump trace: (if you get a core dump):

        no core dump

        This report was generated by /usr/bin/mp2bug on Thu Oct 2 23:47:18 2003 GMT.

        -------------8<---------- End Bug Report --------------8<----------
        --
        ------------------------------------------
        Matisse Enzer
        Doodlelab Inc.
        415-925-5294 ext. 212 (office)
        415-225-6703 (mobile)
      • Matisse Enzer
        I mean to say my server is running under http (not https) - (It is running on port 9000, in case that makes a differece.) and it didn t seem to work. My
        Message 3 of 15 , Oct 2, 2003
          I mean to say my server is running under http (not https) - (It is running
          on port 9000, in case that makes a differece.)


          and it didn't seem to work. My server is on port 9000 but I got
          nothing in $scheme.

          --
          ------------------------------------------
          Matisse Enzer
          Doodlelab Inc.
          415-925-5294 ext. 212 (office)
          415-225-6703 (mobile)
        • Stas Bekman
          ... Ai, my bad, sorry about that. I *should* have tested that. I don t think you can get the request s scheme, because the server doesn t know it. it s only
          Message 4 of 15 , Oct 2, 2003
            Matisse Enzer wrote:
            >
            >
            >
            > -------------8<---------- Start Bug Report ------------8<----------
            > 1. Problem Description:
            >
            > I tried:
            > my $scheme = APR::URI->parse($r->pool, $r->uri)->scheme;
            >
            > and it didn't seem to work. My server is on port 9000 but I got nothing
            > in $scheme.

            Ai, my bad, sorry about that. I *should* have tested that.

            I don't think you can get the request's scheme, because the server doesn't
            know it. it's only used by the client. The server gets only the request URI.

            You can get the scheme only if you know the whole thing, e.g.:

            APR::URI->parse($r->pool, "http://localhost:9000/foo/bar")->scheme;

            You can check what's the currently used protocol with $r->protocol, but it'll
            be the same with http:// and https://. CGI.pm does:

            sub protocol {
            local($^W)=0;
            my $self = shift;
            return 'https' if uc($self->https()) eq 'ON';
            return 'https' if $self->server_port == 443;
            my $prot = $self->server_protocol;
            my($protocol,$version) = split('/',$prot);
            return "\L$protocol\E";
            }

            so you can either use CGI.pm or copy it away.

            __________________________________________________________________
            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
          • Geoffrey Young
            ... there was a way to do this in mod_perl 1.0. I ll take a look tomorrow and see if the same functionality was copied over. --Geoff
            Message 5 of 15 , Oct 2, 2003
              Stas Bekman wrote:
              > Matisse Enzer wrote:
              >
              >>
              >>
              >>
              >> -------------8<---------- Start Bug Report ------------8<----------
              >> 1. Problem Description:
              >>
              >> I tried:
              >> my $scheme = APR::URI->parse($r->pool, $r->uri)->scheme;
              >>
              >> and it didn't seem to work. My server is on port 9000 but I got
              >> nothing in $scheme.
              >
              >
              > Ai, my bad, sorry about that. I *should* have tested that.
              >
              > I don't think you can get the request's scheme, because the server
              > doesn't know it. it's only used by the client. The server gets only the
              > request URI.

              there was a way to do this in mod_perl 1.0. I'll take a look tomorrow and
              see if the same functionality was copied over.

              --Geoff
            • Matisse Enzer
              Thanks, I ll use the return https if uc($self- https()) eq ON ; approach. ... -- ... Matisse Enzer Doodlelab Inc. 415-925-5294 ext. 212 (office)
              Message 6 of 15 , Oct 2, 2003
                Thanks,

                I'll use the

                return 'https' if uc($self->https()) eq 'ON';

                approach.


                At 5:06 PM -0700 10/2/03, Stas Bekman wrote:
                >Matisse Enzer wrote:
                >>
                >>
                >>
                >>-------------8<---------- Start Bug Report ------------8<----------
                >>1. Problem Description:
                >>
                >>I tried:
                >> my $scheme = APR::URI->parse($r->pool, $r->uri)->scheme;
                >>
                >>and it didn't seem to work. My server is on port 9000 but I got
                >>nothing in $scheme.
                >
                >Ai, my bad, sorry about that. I *should* have tested that.
                >
                >I don't think you can get the request's scheme, because the server
                >doesn't know it. it's only used by the client. The server gets only
                >the request URI.
                >
                >You can get the scheme only if you know the whole thing, e.g.:
                >
                > APR::URI->parse($r->pool, "http://localhost:9000/foo/bar")->scheme;
                >
                >You can check what's the currently used protocol with $r->protocol,
                >but it'll be the same with http:// and https://. CGI.pm does:
                >
                >sub protocol {
                > local($^W)=0;
                > my $self = shift;
                > return 'https' if uc($self->https()) eq 'ON';
                > return 'https' if $self->server_port == 443;
                > my $prot = $self->server_protocol;
                > my($protocol,$version) = split('/',$prot);
                > return "\L$protocol\E";
                >}
                >
                >so you can either use CGI.pm or copy it away.
                >
                >__________________________________________________________________
                >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


                --
                ------------------------------------------
                Matisse Enzer
                Doodlelab Inc.
                415-925-5294 ext. 212 (office)
                415-225-6703 (mobile)
              Your message has been successfully submitted and would be delivered to recipients shortly.