httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Tharp" <jth...@esri.com>
Subject Best way for a module to retrieve the full original URL?
Date Mon, 03 Dec 2007 08:30:46 GMT
Hello, I'm hoping someone can point me in the right direction here.  I'm
working on an authentication module for 2.2 that needs to determine the
originally requested URL.  I plan to use this to redirect to an in-house
developed authentication system that then redirects back to the original
web site when it's finished.  My module is currently using the
check_user_id hook.

The best stab I've been able to take at this so far is to use the
following:

static int do_redirect(request_rec *r)
{
    char *orig_uri;
    orig_uri = ap_construct_url(r->pool, r->unparsed_uri, r);
...

The problem with this approach is that I seem to loose URL fragments,
such that when I request http://server.domain.com/index.html#anchor,
orig_uri = "http://server.domain.com/index.html", not
"http://server.domain.com/index.html#anchor".  Is this expected, or am I
going about this in the wrong fashion?  BTW, I realize that this is
somewhat complicated by rewriting and so forth that might have happened
by the time my module processes the request...I think this is okay,
however, as I only need to determine a URL that will return the user
back to the same location that would have been accessed had
authentication not been required.

A somewhat related question, if someone is really feeling really
generous, is what would be the best way to URL-encode the orig_uri
string in a clean portable fashion?  My end goal here is to be able to
redirect to something like
http://login.domain.com/login?action=formlogin&return=<orig_uri>.  Is
ap_escape_path_segment() the best function for this, or do I need to
write my own url-encoding function to meet my needs?  I hacked something
together for now on my own, but it's not portable.

I would greatly appreciate any suggestions regarding either of these
questions.

Thanks,
Jeff Tharp
System Administrator
ESRI - Redlands, CA
http://www.esri.com

Mime
View raw message