How to parse HTTP time header?

Kevin Ar18 kevinar18 at hotmail.com
Sat Nov 7 23:46:42 EST 2009


>>>> Page 20 of RFC2616 (HTTP) describes the format(s) for the time
>>>> header.  It wouldn't be too difficult for me to code up a solution
>>>> for the 3 standard formats, but what get's me is the little note
>>>> about how some servers may still send badly format time headers. :(
>>>> So, I'm curious if this has already been done in the standard Python
>>>> library?
>>>
>>> The parsedate() function in the rfc822 module does this and claims to
>>> be tolerant of slightly malformed dates, but that module is  
>>> deprecated
>>> as of Python 2.5 in favor of the email module which hopefully has an
>>> equivalent function.
>> Thanks, I'll give 'em a look. :)
> Sorry, my mistake -- 2616 != 2822. I'm not sure if there's something  
> in the standard library for parsing RFC 2616 dates.
>
> When I faced the problem of parsing HTTP dates, I wrote my own  
> function although this was in an application that was deliberately  
> unforgiving of invalid input and therefore my code makes no allowances  
> for it. FWIW, it parsed over 1 million dates without encountering any  
> that raised an error.
> 
> Here it is, written in a time when I obviously didn't have total  
> respect for PEP 8.
That's exactly what I had in mind when I said, I could write one quickly.  :)  I guess I can always do it that way if the email.util one doesn't work right. :)Thanks,Kevin 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with Microsoft's powerful SPAM protection.
http://clk.atdmt.com/GBL/go/177141664/direct/01/
http://clk.atdmt.com/GBL/go/177141664/direct/01/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091107/5e84fb9a/attachment.html>


More information about the Python-list mailing list