Mercurial > cosocket
changeset 91:ef9ae587a0c8
Fixed misbehaving redirect URL matching and added a robots.txt.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 01 May 2009 17:50:08 -0700 |
parents | 0b8c3a21335c |
children | 1414765e0929 |
files | openwebchat.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/openwebchat.py Fri May 01 17:38:44 2009 -0700 +++ b/openwebchat.py Fri May 01 17:50:08 2009 -0700 @@ -21,6 +21,8 @@ KEEP_ALIVE_TIMEOUT = int(DEFAULT_TIMEOUT) MAX_MESSAGE_SIZE = 8192 +ROBOTS_TXT = "User-agent: *\r\nDisallow: /" + class Conversations(object): def __init__(self): self._convs = weakref.WeakValueDictionary() @@ -63,7 +65,7 @@ class OpenWebChatServer(object): QUERYSTRING_TEMPLATE = re.compile('([^\?]*)\?(.*)') - REDIRECT_TEMPLATE = re.compile('\/([A-Za-z0-9_]+)') + REDIRECT_TEMPLATE = re.compile('\/([A-Za-z0-9_]+)$') URL_TEMPLATE = re.compile('\/([A-Za-z0-9_]+)/(.*)') BOUNDARY = "'''" @@ -237,6 +239,8 @@ code = 301, additional_headers = {'Location': newpath} ) + elif req_parts[1] == '/robots.txt': + yield self._until_http_response_sent(ROBOTS_TXT) else: yield self._until_http_response_sent('not found', code = 404)