[Twisted-Python] twisted/protocols/http.py stringToDatetime
Hi; I am new to the list, and to Twisted. I was playing with the twisted webserver and found a bug that seems to come up when accessing web pages using an old version of netscape. I am using: Netscape Navigator 4.08 FreeBSD 4.5-RELEASE Twisted 0.19 (from FreeBSD ports) The error would occur when trying to reload a page which had been changed, and seems to be caused by the way the date is being sent from the browser to the server. I am able to work around the problem, by just using a pre-set date if there is a problem parsing that date, as this patch shows: *** http.py.1 Sat Aug 17 12:44:45 2002 --- http.py Sat Aug 17 12:45:39 2002 *************** *** 204,214 **** def stringToDatetime(dateString): """Convert an HTTP date string to seconds since epoch.""" ! parts = string.split(dateString, ' ') ! day = int(parts[1]) ! month = int(monthname.index(parts[2])) ! year = int(parts[3]) ! hour, min, sec = map(int, string.split(parts[4], ':')) return int(timegm(year, month, day, hour, min, sec)) def toChunk(data): --- 204,217 ---- def stringToDatetime(dateString): """Convert an HTTP date string to seconds since epoch.""" ! try: ! parts = string.split(dateString, ' ') ! day = int(parts[1]) ! month = int(monthname.index(parts[2])) ! year = int(parts[3]) ! hour, min, sec = map(int, string.split(parts[4], ':')) ! except: ! day, month, year, hour, min, sec = 1, 1, 1970, 1, 1, 1 return int(timegm(year, month, day, hour, min, sec)) def toChunk(data): Lee Harr missive@hotmail.com _________________________________________________________________ Send and receive Hotmail on your mobile device: http://mobile.msn.com
participants (1)
-
Lee Harr