[Python-bugs-list] rfc822 (PR#358)
jbearce@copeland.com
jbearce@copeland.com
Thu, 15 Jun 2000 19:37:02 -0400 (EDT)
Full_Name: Jim Bearce
Version: 1.5.2
OS: RedHat Linux 6.2
Submission from: corporate.copeland.com (209.191.12.130)
For very long headers returned from a web server rfc822.readheaders does not
correctly build the header.
The following patch fixes it in my situation but I don't know if I broke
anything else:
Example Header:
Location: https://www.website.com:443/tengah/Dpc/vContent.jhtml?page_type=3&PLANID=4&CONTENTPAGEID=0&TengahSession=312442259237-529/2748412123003458168/-1407548368/4/7002/7002/7004/7004
This ends up as
https://www.website.com:443/tengah/Dpc/vContent.jhtml?page_type=3&PLA
and the rest of the header (along with any headers following this one) get
returned as part of the message.
--- /usr/lib/python1.5/rfc822.py.orig Thu Jun 15 19:35:42 2000
+++ /usr/lib/python1.5/rfc822.py Thu Jun 15 19:36:00 2000
@@ -125,6 +125,7 @@
self.status = ''
headerseen = ""
firstline = 1
+ lastheader = ''
startofline = unread = tell = None
if hasattr(self.fp, 'unread'):
unread = self.fp.unread
@@ -150,16 +151,22 @@
continue
elif self.iscomment(line):
# It's a comment. Ignore it.
+ lastheader = ''
continue
elif self.islast(line):
# Note! No pushback here! The delimiter line gets eaten.
+ lastheader = ''
break
headerseen = self.isheader(line)
if headerseen:
# It's a legal header line, save it.
list.append(line)
self.dict[headerseen] = string.strip(line[len(headerseen)+2:])
+ lastheader = headerseen
continue
+ elif lastheader:
+ list.append(line)
+ self.dict[lastheader] = self.dict[lastheader] +
string.strip(line)
else:
# It's not a header line; throw it back and stop here.
if not self.dict: