2005/11/30, Jim Gallacher <[EMAIL PROTECTED]>:

At this point I think we should leave parsed_uri alone, as it seems to
do the correct thing - if not the desired thing. At a minimum we should
expand the documentation to warn people of the limitations. I still
think it would be useful to have a tuple similar to parsed_uri, but
which is fully populated. Or maybe everyone just continues to roll there
  own.

Regards,
Jim


Well, I'm still interested in writing a function that would return a fully populated parsed_uri-like structure, even in the absence of an absolute URL in the request path. Call me stubborn, but I still feel that using a configuration item to tell mod_python the supposed protocol, server name and listening port is a blatant breach of the DRY principle. Plus, it would force me to change the configuration file between my development, test and production platform...Yeah, I'm that lazy :).

So, based on Daniel's excellent posts (thanks, Daniel), here what we have so far :

1) Protocol : http:// or https:// ?

For now the best way to get this is to call req.add_common_vars() and test whether req.subprocess_env.get('HTTPS') == 'on'. Using req.is_https() which was proposed in the other thread "Calling APR optional functions provided by modules" may be more elegant, but right now we don't have this method.

2) Server name

Thanks to Daniel's excellent posts, I can see that req.hostname is the best way to get the server name so far. Unfortunately, it depends on data sent by the client, but hey, so does the rest of the request handling ;).

One thing that would be nice is to let Apache sort out this mess and tell us what is the virtual host name it choose to serve the request. This is my Holy Grail and I shall seek it from now on.

Ah, while I'm at it, knowing the DocumentRoot of the current VirtualHost would be great, too. But that's another story.

3) Port number

port = req.connection.local_addr[1]

'nuf said.

4) URL or URI or whatever you choose to name the part of the resource one the physical matters of protocol, server and port are sorted out

uri = req.uri

Note that this uri can in turn be splitted in something which is lost by the publisher and the req.path_info field, that is IIRC that we can assert(req.uri.endswith(req.path_info)). I don't know what req.path_info is before the publisher kicks in, though.

Anyway, the length of this thread shows that a bit of clarification is required. A page named something like "What's in an URL ?" and explaining the client-side and server-side view of the various components of a URL are would be great. I'll try to write a draft this week-end.

Regards,
Nicolas

Reply via email to