On Thu, 2007-03-29 at 12:56 +1000, Brett Nash wrote:
> Hello,
>       Just working on parsing the tp URI scheme.
> 
>       Anyway, I want to parse it correctly, so I'm curious if it is something
> like this: (perl regex)
>       (tp|http)s?://(user(:password)?@)?server(:port)?/(.*)
> 
> So a few questions:
>  Is this correct?

Looks almost okay. The URL (given to a client) can start with any of the
following,

tp://
tps://
http://
https://
tphttp://
tphttps://

>  Is there any other transport protocols?

Not at the moment.

>  The (.*) is there for http only I assume?  (I assume it is needed for http)

The (.*) is the "game name". On servers which have only one game it can
be ignored. On servers which have multiple games it should be appended
to the username.

>  How does one specify a game to join if the server has support for
> multiple games?

See above.

>  Should http games be specified as tp+http or similar?

Do you know if tp+http is a valid name, it would be better then tphttp
which we currently use.

> Also, is it worthwhile starting the scheme registration process for the
> tp (and tp+http) scheme?

scheme registration process?

The tpclient-pywx registers for tp, tps, tphttp and tphttps links in
Windows and Gnome.

> And can this be put up on the website, or if it is there, linked from
> the protocol doc ;-)

It'll go in the protocol4 document.

>       Regards,
>       nash

This is what the Python protocol library does. It should handle the
cases where some information is left out (IE username).

Hope this helps.

Tim Ansell


def url2bits(line):
        urlspliter = r'(.*?://)?(((.*):(.*)@)|(.*)@)?(.*?)(:(.*?))?(/.*?)?$'
        groups = re.compile(urlspliter, re.M).search(line).groups()
        
        proto = groups[0]

        if not groups[3] is None:
                username = groups[3]
        elif not groups[5] is None:
                username = groups[5]
        else:
                username = None

        server = groups[6]
        port = groups[8]

        password = groups[4]
        if not password is None:
                if password[-1] is '@':
                        password = password[:-1]

        game = groups[9]
        if not game is None:
                game = urllib.unquote_plus(game)
                if game[0] == '/':
                        game = game[1:]
                if len(game) == 0:
                        game = None

        if proto is None:
                one = server
        else:
                one = "%s%s" % (proto, server)

        if not port is None:
                one = "%s:%s" % (one, port)

        return (one, username, game, password)

_______________________________________________
tp-devel mailing list
[email protected]
http://www.thousandparsec.net/tp/mailman.php/listinfo/tp-devel

Reply via email to