Menu

#71 ns_conn seturl newUrl

open
nobody
None
5
2004-08-22
2004-08-22
Stephen
No

This patch adds a couple of new features for handling URLs:

Ns_ConnSetUrl(Ns_Conn *conn)
ns_conn url ?newUrl?

These two enable you to change the URL of the current
request, perhaps from a preauth filter to enable url
rewriting.

There is an existing C API for this already:
Ns_SetRequestUrl(), but consider the following:

Ns_ConnUrl(Ns_Conn *conn)
Ns_ConnOriginalUrl(Ns_Conn *conn)
ns_conn originalurl

Using the old Ns_SetRequestUrl API, the original URL as
sent by the browser is lost. The new C and Tcl APIs
keep around a copy of the original. Only the original
is kept, i.e. you may reset the URL multiple times but
only the URL originaly sent by the browser is saved.

I've also updated Ns_ConnRedirect() to use
Ns_ConnSetUrl(), which means that if you set custom
error messages up in your config file:

ns_section "ns/server/${servicename}/redirects"
ns_param 404 "/global/notfound.adp"

you can access the original URL from within the
notfound.adp, perhaps searching for a something
suitable, like Apache's mod_spelling.

This patch also fixes a small bug with the custom error
handler. It keeps track of the recursion count, which
maxes out at 3, but it never resets it to zero. The
effect you see is that as you click reload in your
browser for the fourth time for some non existant page,
your custom error handler stops working.

Discussion

  • Stephen

    Stephen - 2004-08-22

    Logged In: YES
    user_id=87254

    Updated patch. The optional third argument to 'ns_conn url'
    clashes with ancient code that still passes round an
    unneeded connid.

    Instead, I've added the new ns_conn subcommand 'seturl'.

     
  • Stephen

    Stephen - 2004-08-22

    Implements [ns_conn seturl newUrl] etc.

     
  • Stephen

    Stephen - 2004-08-22
    • summary: ns_conn url ?newUrl? --> ns_conn seturl newUrl
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.