class_docstr: Store a sequence of fields, reading multipart/form-data.
  
  This class provides naming, typing, files stored on disk, and
  more.  At the top level, it is accessible like a dictionary, whose
  keys are the field names.  (Note: None can occur as a field name.)
  The items are either a Python list (if there's multiple values) or
  another FieldStorage or MiniFieldStorage object.  If it's a single
  object, it has the following attributes:
  
  name: the field name, if specified; otherwise None
  
  filename: the filename, if specified; otherwise None; this is the
      client side filename, *not* the file name on which it is
      stored (that's a temporary file you don't deal with)
  
  value: the value as a *string*; for file uploads, this
      transparently reads the file every time you request the value
      and returns *bytes*
  
  file: the file(-like) object from which you can read the data *as
      bytes* ; None if the data is stored a simple string
  
  type: the content-type, or None if not specified
  
  type_options: dictionary of options specified on the content-type
      line
  
  disposition: content-disposition, or None if not specified
  
  disposition_options: dictionary of corresponding options
  
  headers: a dictionary(-like) object (sometimes email.message.Message or a
      subclass thereof) containing *all* headers
  
  The class is subclassable, mostly for the purpose of overriding
  the make_file() method, which is called internally to come up with
  a file open for reading and writing.  This makes it possible to
  override the default choice of storing all files in a temporary
  directory and unlinking them as soon as they have been opened.
class_docstr_tok: ["Store","a","sequence","of","fields",",","reading","multipart\/form-data",".","This","class","provides","naming",",","typing",",","files","stored","on","disk",",","and","more",".","At","the","top","level",",","it","is","accessible","like","a","dictionary",",","whose","keys","are","the","field","names",".","(","Note",":","None","can","occur","as","a","field","name",".",")","The","items","are","either","a","Python","list","(","if","there","'s","multiple","values",")","or","another","FieldStorage","or","MiniFieldStorage","object",".","If","it","'s","a","single","object",",","it","has","the","following","attributes",":","name",":","the","field","name",",","if","specified",";","otherwise","None","filename",":","the","filename",",","if","specified",";","otherwise","None",";","this","is","the","client","side","filename",",","*","not","*","the","file","name","on","which","it","is","stored","(","that","'s","a","temporary","file","you","do","n't","deal","with",")","value",":","the","value","as","a","*","string","*",";","for","file","uploads",",","this","transparently","reads","the","file","every","time","you","request","the","value","and","returns","*","bytes","*","file",":","the","file","(","-like",")","object","from","which","you","can","read","the","data","*","as","bytes","*",";","None","if","the","data","is","stored","a","simple","string","type",":","the","content-type",",","or","None","if","not","specified","type_options",":","dictionary","of","options","specified","on","the","content-type","line","disposition",":","content-disposition",",","or","None","if","not","specified","disposition_options",":","dictionary","of","corresponding","options","headers",":","a","dictionary","(","-like",")","object","(","sometimes","email.message.Message","or","a","subclass","thereof",")","containing","*","all","*","headers","The","class","is","subclassable",",","mostly","for","the","purpose","of","overriding","the","make_file","(",")","method",",","which","is","called","internally","to","come","up","with","a","file","open","for","reading","and","writing",".","This","makes","it","possible","to","override","the","default","choice","of","storing","all","files","in","a","temporary","directory","and","unlinking","them","as","soon","as","they","have","been","opened","."]
docstr: Constructor.  Read multipart/* until last part.
  
  Arguments, all optional:
  
  fp              : file pointer; default: sys.stdin.buffer
      (not used when the request method is GET)
      Can be :
      1. a TextIOWrapper object
      2. an object whose read() and readline() methods return bytes
  
  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.
  
  limit : used internally to read parts of multipart/form-data forms,
      to exit from the reading loop when reached. It is the difference
      between the form content-length and the number of bytes already
      read
  
  encoding, errors : the encoding and error handler used to decode the
      binary stream to strings. Must be the same as the charset defined
      for the page sending the form (content-type : meta http-equiv or
      header)
  
  max_num_fields: int. If set, then __init__ throws a ValueError
      if there are more than n fields read by parse_qsl().
docstr_tok: ["Constructor",".","Read","multipart\/","*","until","last","part",".","Arguments",",","all","optional",":","fp",":","file","pointer",";","default",":","sys.stdin.buffer","(","not","used","when","the","request","method","is","GET",")","Can","be",":","1.","a","TextIOWrapper","object","2.","an","object","whose","read","(",")","and","readline","(",")","methods","return","bytes","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",".","limit",":","used","internally","to","read","parts","of","multipart\/form-data","forms",",","to","exit","from","the","reading","loop","when","reached",".","It","is","the","difference","between","the","form","content-length","and","the","number","of","bytes","already","read","encoding",",","errors",":","the","encoding","and","error","handler","used","to","decode","the","binary","stream","to","strings",".","Must","be","the","same","as","the","charset","defined","for","the","page","sending","the","form","(","content-type",":","meta","http-equiv","or","header",")","max_num_fields",":","int",".","If","set",",","then","__init__","throws","a","ValueError","if","there","are","more","than","n","fields","read","by","parse_qsl","(",")","."]
code: def __init__(
      self,
      fp=None,
      headers=None,
      outerboundary=b"",
      environ=os.environ,
      keep_blank_values=0,
      strict_parsing=0,
      limit=None,
      encoding="utf-8",
      errors="replace",
      max_num_fields=None,
      separator="&",
  ):
      """Constructor.  Read multipart/* until last part.
  
      Arguments, all optional:
  
      fp              : file pointer; default: sys.stdin.buffer
          (not used when the request method is GET)
          Can be :
          1. a TextIOWrapper object
          2. an object whose read() and readline() methods return bytes
  
      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.
  
      limit : used internally to read parts of multipart/form-data forms,
          to exit from the reading loop when reached. It is the difference
          between the form content-length and the number of bytes already
          read
  
      encoding, errors : the encoding and error handler used to decode the
          binary stream to strings. Must be the same as the charset defined
          for the page sending the form (content-type : meta http-equiv or
          header)
  
      max_num_fields: int. If set, then __init__ throws a ValueError
          if there are more than n fields read by parse_qsl().
  
      """
      method = "GET"
      self.keep_blank_values = keep_blank_values
      self.strict_parsing = strict_parsing
      self.max_num_fields = max_num_fields
      self.separator = separator
      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 = ""
          qs = qs.encode(
              locale.getpreferredencoding(), "surrogateescape"
          )
          fp = BytesIO(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"]
      else:
          if not (isinstance(headers, (Mapping, Message))):
              raise TypeError(
                  "headers must be mapping or an instance of "
                  "email.message.Message"
              )
      self.headers = headers
      if fp is None:
          self.fp = sys.stdin.buffer
      # self.fp.read() must return bytes
      elif isinstance(fp, TextIOWrapper):
          self.fp = fp.buffer
      else:
          if not (hasattr(fp, "read") and hasattr(fp, "readline")):
              raise TypeError("fp must be file pointer")
          self.fp = fp
  
      self.encoding = encoding
      self.errors = errors
  
      if not isinstance(outerboundary, bytes):
          raise TypeError(
              "outerboundary must be bytes, not %s"
              % type(outerboundary).__name__
          )
      self.outerboundary = outerboundary
  
      self.bytes_read = 0
      self.limit = limit
  
      # 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"]
      self._binary_file = self.filename is not None
  
      # 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
      if "boundary" in pdict:
          self.innerboundary = pdict["boundary"].encode(
              self.encoding, self.errors
          )
      else:
          self.innerboundary = b""
  
      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
      if self.limit is None and clen >= 0:
          self.limit = 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()
  
imports: from io import StringIO, BytesIO, TextIOWrapper
  from collections.abc import Mapping
  import sys
  import os
  import urllib.parse
  from email.parser import FeedParser
  from email.message import Message
  import html
  import locale
  import tempfile
  import warnings
label_desc: Use image node_id 1 to create a new FieldStorage object  with example: obj = FieldStorage(fp, headers, outerboundary, environ, keep_blank_values, strict_parsing, limit, encoding, errors, max_num_fields, separator)