def __init__(self, environ, base_paths=None):
self.headers = util.get_headers_from_environ(environ)<EOL>self.http_method = environ['<STR_LIT>']<EOL>self.url_scheme = environ['<STR_LIT>']<EOL>self.server = environ['<STR_LIT>']<EOL>self.port = environ['<STR_LIT>']<EOL>self.path = environ['<STR_LIT>']<EOL>self.request_uri = environ.get('<STR_LIT>')<EOL>if self.request_uri is not None and len(self.request_uri) < len(self.path):<EOL><INDENT>self.request_uri = None<EOL><DEDENT>self.query = environ.get('<STR_LIT>')<EOL>self.body = environ['<STR_LIT>'].read()<EOL>if self.body and self.headers.get('<STR_LIT>') == '<STR_LIT>':<EOL><INDENT>try:<EOL><INDENT>self.body = zlib.decompress(self.body, <NUM_LIT:16> + zlib.MAX_WBITS)<EOL><DEDENT>except zlib.error:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if _METHOD_OVERRIDE in self.headers:<EOL><INDENT>self.http_method = self.headers[_METHOD_OVERRIDE]<EOL>del self.headers[_METHOD_OVERRIDE]  <EOL><DEDENT>self.source_ip = environ.get('<STR_LIT>')<EOL>self.relative_url = self._reconstruct_relative_url(environ)<EOL>if not base_paths:<EOL><INDENT>base_paths = set()<EOL><DEDENT>elif isinstance(base_paths, list):<EOL><INDENT>base_paths = set(base_paths)<EOL><DEDENT>for base_path in base_paths:<EOL><INDENT>if self.path.startswith(base_path):<EOL><INDENT>self.path = self.path[len(base_path):]<EOL>if self.request_uri is not None:<EOL><INDENT>self.request_uri = self.request_uri[len(base_path):]<EOL><DEDENT>self.base_path = base_path<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>' % self.path)<EOL><DEDENT>if self.query:<EOL><INDENT>self.parameters = urlparse.parse_qs(self.query, keep_blank_values=True)<EOL><DEDENT>else:<EOL><INDENT>self.parameters = {}<EOL><DEDENT>self.body_json = self._process_req_body(self.body) if self.body else {}<EOL>self.request_id = None<EOL>if isinstance(self.body_json, list):<EOL><INDENT>if len(self.body_json) != <NUM_LIT:1>:<EOL><INDENT>_logger.warning('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>len(self.body_json))<EOL><DEDENT>else:<EOL><INDENT>_logger.info('<STR_LIT>')<EOL><DEDENT>self.body_json = self.body_json[<NUM_LIT:0>]<EOL>self.body = json.dumps(self.body_json)<EOL>self._is_batch = True<EOL><DEDENT>else:<EOL><INDENT>self._is_batch = False<EOL><DEDENT>
Constructor.

        Args:
          environ: An environ dict for the request as defined in PEP-333.

        Raises:
          ValueError: If the path for the request is invalid.