Issue Details (XML | Word | Printable)

Key: MODPYTHON-132
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Graham Dumpleton
Reporter: Graham Dumpleton
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
mod_python

Expose ap_construct_url() in request object.

Created: 17/Feb/06 09:59 AM   Updated: 11/Apr/07 11:26 AM
Return to search
Component/s: core
Affects Version/s: 3.3.x
Fix Version/s: 3.3.1

Time Tracking:
Not Specified

Resolution Date: 07/Mar/06 09:26 AM


 Description  « Hide
Apache provides the function ap_construct_url(). Its purpose is:

  char *ap_construct_url (pool *p, const char *uri, const request_rec *r)

    This function builds a fully qualified URI string from the path specified
    by uri, using the information stored in the request record r to determine
    the server name and port. The port number is not included in the string
    if it is the same as the default port 80.

    For example, imagine that the current request is directed to the virtual
    server www.modperl.com at port 80. Then the following call will return
    the string http://www.modperl.com/ index.html:

        char *url = ap_construct_url(r->pool, "/index.html", r);

This may be a solution to issue previously discussed about how to create a full URL for purpose of doing a redirect.

Even if not perfect, should be exposed as req.construct_url(). After all, the Apache folks are more likely to get this correct and maintain it, better than we can do our own version in Python.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #379078 Mon Feb 20 10:59:41 UTC 2006 grahamd New req.construct_url() method. Used to construct a fully qualified URI
string incorporating correct scheme, server and port. (MODPYTHON-132)
Files Changed
MODIFY /httpd/mod_python/trunk/test/htdocs/tests.py
MODIFY /httpd/mod_python/trunk/Doc/modpython4.tex
MODIFY /httpd/mod_python/trunk/test/test.py
MODIFY /httpd/mod_python/trunk/src/requestobject.c
MODIFY /httpd/mod_python/trunk/Doc/appendixc.tex

Graham Dumpleton added a comment - 01/Mar/06 08:15 PM
This ap_construct_url() method held so much promise as far as solving the redirection issue. Unfortunately, it seems to get it wrong occasionally. :-(

  req.the_request = GET /~grahamd/authenhandler/?invalidate HTTP/1.1

  req.headers_in["host"] = localhost:8080
  req.connection.local_addr = ('127.0.0.1', 8080)

For whatever reason though in this one case, it spat out:

  http://localhost/~grahamd/authenhandler/login.html

What happened to my port number?

I think it is tied up with fact that request was against a directory and it was doing odd things based on DirectoryIndex value. Ie., Apache was trying multiple alternatives and after first somehow decided to not bother including port properly.

But then, I was trying to use mod_python.util.redirect() in an authenhandler and it looks like the redirect function may actually be buggy. Specifically, mod_python.util.redirect() returns apache.OK when it should actually be returning apache.DONE as it forms a complete response. Because it wasn't returning apache.DONE, Apache kept trying to match files in DirectoryIndex when it should have given up after the first because a redirect response was being returned.

Will have to do some testing and will have to post a distinct issue if it should be changed.

Graham Dumpleton made changes - 05/Mar/06 03:20 PM
Field Original Value New Value
Assignee Graham Dumpleton [ grahamd ]
Fix Version/s 3.3 [ 12310101 ]
Graham Dumpleton made changes - 05/Mar/06 03:43 PM
Status Open [ 1 ] In Progress [ 3 ]
Graham Dumpleton made changes - 07/Mar/06 09:26 AM
Status In Progress [ 3 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Graham Dumpleton made changes - 11/Apr/07 11:26 AM
Status Resolved [ 5 ] Closed [ 6 ]