parameters: (self)
docstring: Read header lines.
  
          Read header lines up to the entirely blank line that terminates them.
          The (normally blank) line that ends the headers is skipped, but not
          included in the returned list.  If a non-header line ends the headers,
          (which is an error), an attempt is made to backspace over it; it is
          never included in the returned list.
  
          The variable self.status is set to the empty string if all went well,
          otherwise it is an error message.  The variable self.headers is a
          completely uninterpreted list of lines contained in the header (so
          printing them will reproduce the header exactly as it appears in the
          file).
docstring_summary: Read header lines.
docstring_tokens: Read header lines .
function: def readheaders(self):
          """Read header lines.
  
          Read header lines up to the entirely blank line that terminates them.
          The (normally blank) line that ends the headers is skipped, but not
          included in the returned list.  If a non-header line ends the headers,
          (which is an error), an attempt is made to backspace over it; it is
          never included in the returned list.
  
          The variable self.status is set to the empty string if all went well,
          otherwise it is an error message.  The variable self.headers is a
          completely uninterpreted list of lines contained in the header (so
          printing them will reproduce the header exactly as it appears in the
          file).
          """
          self.dict = {}
          self.unixfrom = ''
          self.headers = lst = []
          self.status = ''
          headerseen = ""
          firstline = 1
          startofline = unread = tell = None
          if hasattr(self.fp, 'unread'):
              unread = self.fp.unread
          elif self.seekable:
              tell = self.fp.tell
          while 1:
              if tell:
                  try:
                      startofline = tell()
                  except IOError:
                      startofline = tell = None
                      self.seekable = 0
              line = self.fp.readline()
              if not line:
                  self.status = 'EOF in headers'
                  break
              # Skip unix From name time lines
              if firstline and line.startswith('From '):
                  self.unixfrom = self.unixfrom + line
                  continue
              firstline = 0
              if headerseen and line[0] in ' \t':
                  # It's a continuation line.
                  lst.append(line)
                  x = (self.dict[headerseen] + "\n " + line.strip())
                  self.dict[headerseen] = x.strip()
                  continue
              elif self.iscomment(line):
                  # It's a comment.  Ignore it.
                  continue
              elif self.islast(line):
                  # Note! No pushback here!  The delimiter line gets eaten.
                  break
              headerseen = self.isheader(line)
              if headerseen:
                  # It's a legal header line, save it.
                  lst.append(line)
                  self.dict[headerseen] = line[len(headerseen)+1:].strip()
                  continue
              elif headerseen is not None:
                  # An empty header name. These aren't allowed in HTTP, but it's
                  # probably a benign mistake. Don't add the header, just keep
                  # going.
                  continue
              else:
                  # It's not a header line; throw it back and stop here.
                  if not self.dict:
                      self.status = 'No headers'
                  else:
                      self.status = 'Non-header line where header expected'
                  # Try to undo the read.
                  if unread:
                      unread(line)
                  elif tell:
                      self.fp.seek(startofline)
                  else:
                      self.status = self.status + '; bad seek'
                  break
function_tokens: def readheaders ( self ) : self . dict = { } self . unixfrom = '' self . headers = lst = [ ] self . status = '' headerseen = "" firstline = 1 startofline = unread = tell = None if hasattr ( self . fp , 'unread' ) : unread = self . fp . unread elif self . seekable : tell = self . fp . tell while 1 : if tell : try : startofline = tell ( ) except IOError : startofline = tell = None self . seekable = 0 line = self . fp . readline ( ) if not line : self . status = 'EOF in headers' break # Skip unix From name time lines if firstline and line . startswith ( 'From ' ) : self . unixfrom = self . unixfrom + line continue firstline = 0 if headerseen and line [ 0 ] in ' \t' : # It's a continuation line. lst . append ( line ) x = ( self . dict [ headerseen ] + "\n " + line . strip ( ) ) self . dict [ headerseen ] = x . strip ( ) continue elif self . iscomment ( line ) : # It's a comment.  Ignore it. continue elif self . islast ( line ) : # Note! No pushback here!  The delimiter line gets eaten. break headerseen = self . isheader ( line ) if headerseen : # It's a legal header line, save it. lst . append ( line ) self . dict [ headerseen ] = line [ len ( headerseen ) + 1 : ] . strip ( ) continue elif headerseen is not None : # An empty header name. These aren't allowed in HTTP, but it's # probably a benign mistake. Don't add the header, just keep # going. continue else : # It's not a header line; throw it back and stop here. if not self . dict : self . status = 'No headers' else : self . status = 'Non-header line where header expected' # Try to undo the read. if unread : unread ( line ) elif tell : self . fp . seek ( startofline ) else : self . status = self . status + '; bad seek' break