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

internal_redirect to randomly named filename

Expand Messages
  • dreamwvr@dreamwvr.com
    Hi All, Since lookup_uri() is only to be used when the actual URI physically exists. Having said that how does not tell it to pretend that a randomly generated
    Message 1 of 20 , Feb 2, 2004
    • 0 Attachment
      Hi All,
      Since lookup_uri() is only to be used when the actual
      URI physically exists. Having said that how does not tell
      it to pretend that a randomly generated virtual file exists?
      Is that what lookup_filename() is for? I am wanting to do a
      internal_redirect() to a virtual file whose name is always
      changing. This way the Location is never the same twice.
      Any suggestions appreciated.

      TIA
      Best Regards,
      dreamwvr@...

      --
      /* Security is a work in progress - dreamwvr */
      # 48 69 65 72 6F 70 68 61 6E 74 32
      # Note: To begin Journey type man afterboot,man help,man hier[.]
      # 66 6F 72 20 48 69 72 65 0000 0001
      // "Who's Afraid of Schrodinger's Cat?" /var/(.)?mail/me \? ;-]

      --
      Reporting bugs: 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
      ... lookup_uri() will issue a subrequest that includes URI- filename translation. lookup_file() will skip over the translation part, setting $r- filename to
      Message 2 of 20 , Feb 3, 2004
      • 0 Attachment
        dreamwvr@... wrote:
        > Hi All,
        > Since lookup_uri() is only to be used when the actual
        > URI physically exists. Having said that how does not tell
        > it to pretend that a randomly generated virtual file exists?
        > Is that what lookup_filename() is for?

        lookup_uri() will issue a subrequest that includes URI->filename
        translation. lookup_file() will skip over the translation part, setting
        $r->filename to the file you pass in. I suppose that you could use this to
        avoid the IO if you know the file doesn't exist, but I've never tried. from
        the code it looks like it should work ok - $r->filename is set but
        meaningless for dynamic documents anyway.

        > I am wanting to do a
        > internal_redirect() to a virtual file whose name is always
        > changing. This way the Location is never the same twice.
        > Any suggestions appreciated.

        I don't see why you need to use either with internal_redirect() - just pass
        it the URI and let Apache handle it. you would use a subrequest (initiated
        from eather of the lookup functions) along with $sub->run() if you wanted to
        send the contents of the subrequest along.

        HTH

        --Geoff


        --
        Reporting bugs: 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
      • dreamwvr@dreamwvr.com
        ... (For the archives since It might be useful info.. them again maybe not.:-) Well, I was hoping this was the case however this is what happens.. [...] $sub =
        Message 3 of 20 , Feb 10, 2004
        • 0 Attachment
          On Tue, Feb 03, 2004 at 11:09:31AM -0500, Geoffrey Young wrote:
          > I don't see why you need to use either with internal_redirect() - just pass
          > it the URI and let Apache handle it. you would use a subrequest (initiated
          > from eather of the lookup functions) along with $sub->run() if you wanted to
          > send the contents of the subrequest along.
          (For the archives since It might be useful info.. them again maybe not.:-)
          Well, I was hoping this was the case however this is what happens..
          [...]
          $sub = $r->lookup_file("randfile.html");
          $filename = $sub->filename();
          [...]
          $sub->internal_redirect($filename);
          $sub->run() and return 'OK';

          if($sub->run ne 'OK') {

          $sub->log_error("Error running subrequest!");

          }
          Just tried this and I get the usual file_not_found page..
          Not Found

          The requested URL /var/www/htdocs/test/randfile.html was not found on this server.
          FYI:
          If one uses the internal_redir* with lookup_file() the above err is what occurs.
          If one uses the internal_redir* with lookup_uri() and the file exists
          one does get the page. So me thinks I am missing something obvious. Is it?
          thought train was that subrequests make Apache reload the page as if it was
          a completely new request. That way redirection would occur simularly to
          META tags redirection when set to "0" seconds. Well back to it.

          Best Regards,
          dreamwvr@...



          --
          Reporting bugs: 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
          ... take a look at the internal_redirect docs - once you call internal_redirect you need to return OK - no additional logic is allowed. so, you can t both
          Message 4 of 20 , Feb 10, 2004
          • 0 Attachment
            dreamwvr@... wrote:
            > On Tue, Feb 03, 2004 at 11:09:31AM -0500, Geoffrey Young wrote:
            >
            >>I don't see why you need to use either with internal_redirect() - just pass
            >>it the URI and let Apache handle it. you would use a subrequest (initiated
            >>from eather of the lookup functions) along with $sub->run() if you wanted to
            >>send the contents of the subrequest along.
            >
            > (For the archives since It might be useful info.. them again maybe not.:-)
            > Well, I was hoping this was the case however this is what happens..
            > [...]
            > $sub = $r->lookup_file("randfile.html");
            > $filename = $sub->filename();
            > [...]
            > $sub->internal_redirect($filename);
            > $sub->run() and return 'OK';
            >
            > if($sub->run ne 'OK') {
            >
            > $sub->log_error("Error running subrequest!");
            >
            > }
            > Just tried this and I get the usual file_not_found page..
            > Not Found
            >
            > The requested URL /var/www/htdocs/test/randfile.html was not found on this server.
            > FYI:
            > If one uses the internal_redir* with lookup_file() the above err is what occurs.
            > If one uses the internal_redir* with lookup_uri() and the file exists
            > one does get the page. So me thinks I am missing something obvious. Is it?
            > thought train was that subrequests make Apache reload the page as if it was
            > a completely new request. That way redirection would occur simularly to
            > META tags redirection when set to "0" seconds. Well back to it.

            take a look at the internal_redirect docs - once you call internal_redirect
            you need to return OK - no additional logic is allowed. so, you can't both
            $sub->internal_redirect() and $sub->run().

            basically, if in your content handler you want Apache to redirect to a
            different URI use $r->internal_redirect.

            if you want to test attributes of a given URI or file (say, whether the
            current $r->remote_user would be able to view the file if they accessed it
            directly), then you would create a subrequest with lookup_file() or
            lookup_uri(). if you find that the subrequest passes your tests, you can
            $sub->run() to send the file directly to the client, or call whatever logic
            you like to send your own content to the client (including
            $r->internal_redirect).

            HTH

            --Geoff


            --
            Reporting bugs: 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.