def prepare_backend_environ(self, host, method, relative_url, headers, body,<EOL>source_ip, port):
if isinstance(body, unicode):<EOL><INDENT>body = body.encode('<STR_LIT:ascii>')<EOL><DEDENT>url = urlparse.urlsplit(relative_url)<EOL>if port != <NUM_LIT>:<EOL><INDENT>host = '<STR_LIT>' % (host, port)<EOL><DEDENT>else:<EOL><INDENT>host = host<EOL><DEDENT>environ = {'<STR_LIT>': str(len(body)),<EOL>'<STR_LIT>': url.path,<EOL>'<STR_LIT>': url.query,<EOL>'<STR_LIT>': method,<EOL>'<STR_LIT>': source_ip,<EOL>'<STR_LIT>': host,<EOL>'<STR_LIT>': str(port),<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': (<NUM_LIT:1>, <NUM_LIT:0>),<EOL>'<STR_LIT>': '<STR_LIT:http>',<EOL>'<STR_LIT>': cStringIO.StringIO(),<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': True,<EOL>'<STR_LIT>': cStringIO.StringIO(body)}<EOL>util.put_headers_in_environ(headers, environ)<EOL>environ['<STR_LIT>'] = host<EOL>return environ<EOL>
Build an environ object for the backend to consume.

        Args:
          host: A string containing the host serving the request.
          method: A string containing the HTTP method of the request.
          relative_url: A string containing path and query string of the request.
          headers: A list of (key, value) tuples where key and value are both
                   strings.
          body: A string containing the request body.
          source_ip: The source IP address for the request.
          port: The port to which to direct the request.

        Returns:
          An environ object with all the information necessary for the backend to
          process the request.