parameters: (self, fp=None, headers=None, outerboundary="",
                   environ=os.environ, keep_blank_values=0, strict_parsing=0)
docstring: Constructor.  Read multipart/* until last part.
  
          Arguments, all optional:
  
          fp              : file pointer; default: sys.stdin
              (not used when the request method is GET)
  
          headers         : header dictionary-like object; default:
              taken from environ as per CGI spec
  
          outerboundary   : terminating multipart boundary
              (for internal use only)
  
          environ         : environment dictionary; default: os.environ
  
          keep_blank_values: flag indicating whether blank values in
              percent-encoded forms should be treated as blank strings.
              A true value indicates that blanks should be retained as
              blank strings.  The default false value indicates that
              blank values are to be ignored and treated as if they were
              not included.
  
          strict_parsing: flag indicating what to do with parsing errors.
              If false (the default), errors are silently ignored.
              If true, errors raise a ValueError exception.
docstring_summary: Constructor.  Read multipart/* until last part.
docstring_tokens: Constructor . Read multipart / * until last part .
function: def __init__(self, fp=None, headers=None, outerboundary="",
                   environ=os.environ, keep_blank_values=0, strict_parsing=0):
          """Constructor.  Read multipart/* until last part.
  
          Arguments, all optional:
  
          fp              : file pointer; default: sys.stdin
              (not used when the request method is GET)
  
          headers         : header dictionary-like object; default:
              taken from environ as per CGI spec
  
          outerboundary   : terminating multipart boundary
              (for internal use only)
  
          environ         : environment dictionary; default: os.environ
  
          keep_blank_values: flag indicating whether blank values in
              percent-encoded forms should be treated as blank strings.
              A true value indicates that blanks should be retained as
              blank strings.  The default false value indicates that
              blank values are to be ignored and treated as if they were
              not included.
  
          strict_parsing: flag indicating what to do with parsing errors.
              If false (the default), errors are silently ignored.
              If true, errors raise a ValueError exception.
  
          """
          method = 'GET'
          self.keep_blank_values = keep_blank_values
          self.strict_parsing = strict_parsing
          if 'REQUEST_METHOD' in environ:
              method = environ['REQUEST_METHOD'].upper()
          self.qs_on_post = None
          if method == 'GET' or method == 'HEAD':
              if 'QUERY_STRING' in environ:
                  qs = environ['QUERY_STRING']
              elif sys.argv[1:]:
                  qs = sys.argv[1]
              else:
                  qs = ""
              fp = StringIO(qs)
              if headers is None:
                  headers = {'content-type':
                             "application/x-www-form-urlencoded"}
          if headers is None:
              headers = {}
              if method == 'POST':
                  # Set default content-type for POST to what's traditional
                  headers['content-type'] = "application/x-www-form-urlencoded"
              if 'CONTENT_TYPE' in environ:
                  headers['content-type'] = environ['CONTENT_TYPE']
              if 'QUERY_STRING' in environ:
                  self.qs_on_post = environ['QUERY_STRING']
              if 'CONTENT_LENGTH' in environ:
                  headers['content-length'] = environ['CONTENT_LENGTH']
          self.fp = fp or sys.stdin
          self.headers = headers
          self.outerboundary = outerboundary
  
          # Process content-disposition header
          cdisp, pdict = "", {}
          if 'content-disposition' in self.headers:
              cdisp, pdict = parse_header(self.headers['content-disposition'])
          self.disposition = cdisp
          self.disposition_options = pdict
          self.name = None
          if 'name' in pdict:
              self.name = pdict['name']
          self.filename = None
          if 'filename' in pdict:
              self.filename = pdict['filename']
  
          # Process content-type header
          #
          # Honor any existing content-type header.  But if there is no
          # content-type header, use some sensible defaults.  Assume
          # outerboundary is "" at the outer level, but something non-false
          # inside a multi-part.  The default for an inner part is text/plain,
          # but for an outer part it should be urlencoded.  This should catch
          # bogus clients which erroneously forget to include a content-type
          # header.
          #
          # See below for what we do if there does exist a content-type header,
          # but it happens to be something we don't understand.
          if 'content-type' in self.headers:
              ctype, pdict = parse_header(self.headers['content-type'])
          elif self.outerboundary or method != 'POST':
              ctype, pdict = "text/plain", {}
          else:
              ctype, pdict = 'application/x-www-form-urlencoded', {}
          self.type = ctype
          self.type_options = pdict
          self.innerboundary = ""
          if 'boundary' in pdict:
              self.innerboundary = pdict['boundary']
          clen = -1
          if 'content-length' in self.headers:
              try:
                  clen = int(self.headers['content-length'])
              except ValueError:
                  pass
              if maxlen and clen > maxlen:
                  raise ValueError, 'Maximum content length exceeded'
          self.length = clen
  
          self.list = self.file = None
          self.done = 0
          if ctype == 'application/x-www-form-urlencoded':
              self.read_urlencoded()
          elif ctype[:10] == 'multipart/':
              self.read_multi(environ, keep_blank_values, strict_parsing)
          else:
              self.read_single()
function_tokens: def __init__ ( self , fp = None , headers = None , outerboundary = "" , environ = os . environ , keep_blank_values = 0 , strict_parsing = 0 ) : method = 'GET' self . keep_blank_values = keep_blank_values self . strict_parsing = strict_parsing if 'REQUEST_METHOD' in environ : method = environ [ 'REQUEST_METHOD' ] . upper ( ) self . qs_on_post = None if method == 'GET' or method == 'HEAD' : if 'QUERY_STRING' in environ : qs = environ [ 'QUERY_STRING' ] elif sys . argv [ 1 : ] : qs = sys . argv [ 1 ] else : qs = "" fp = StringIO ( qs ) if headers is None : headers = { 'content-type' : "application/x-www-form-urlencoded" } if headers is None : headers = { } if method == 'POST' : # Set default content-type for POST to what's traditional headers [ 'content-type' ] = "application/x-www-form-urlencoded" if 'CONTENT_TYPE' in environ : headers [ 'content-type' ] = environ [ 'CONTENT_TYPE' ] if 'QUERY_STRING' in environ : self . qs_on_post = environ [ 'QUERY_STRING' ] if 'CONTENT_LENGTH' in environ : headers [ 'content-length' ] = environ [ 'CONTENT_LENGTH' ] self . fp = fp or sys . stdin self . headers = headers self . outerboundary = outerboundary # Process content-disposition header cdisp , pdict = "" , { } if 'content-disposition' in self . headers : cdisp , pdict = parse_header ( self . headers [ 'content-disposition' ] ) self . disposition = cdisp self . disposition_options = pdict self . name = None if 'name' in pdict : self . name = pdict [ 'name' ] self . filename = None if 'filename' in pdict : self . filename = pdict [ 'filename' ] # Process content-type header # # Honor any existing content-type header.  But if there is no # content-type header, use some sensible defaults.  Assume # outerboundary is "" at the outer level, but something non-false # inside a multi-part.  The default for an inner part is text/plain, # but for an outer part it should be urlencoded.  This should catch # bogus clients which erroneously forget to include a content-type # header. # # See below for what we do if there does exist a content-type header, # but it happens to be something we don't understand. if 'content-type' in self . headers : ctype , pdict = parse_header ( self . headers [ 'content-type' ] ) elif self . outerboundary or method != 'POST' : ctype , pdict = "text/plain" , { } else : ctype , pdict = 'application/x-www-form-urlencoded' , { } self . type = ctype self . type_options = pdict self . innerboundary = "" if 'boundary' in pdict : self . innerboundary = pdict [ 'boundary' ] clen = - 1 if 'content-length' in self . headers : try : clen = int ( self . headers [ 'content-length' ] ) except ValueError : pass if maxlen and clen > maxlen : raise ValueError , 'Maximum content length exceeded' self . length = clen self . list = self . file = None self . done = 0 if ctype == 'application/x-www-form-urlencoded' : self . read_urlencoded ( ) elif ctype [ : 10 ] == 'multipart/' : self . read_multi ( environ , keep_blank_values , strict_parsing ) else : self . read_single ( )