def perform_request(self, request):
connection = self.get_connection(request)<EOL>try:<EOL><INDENT>connection.putrequest(request.method, request.path)<EOL>self.send_request_headers(connection, request.headers)<EOL>self.send_request_body(connection, request.body)<EOL>if DEBUG_REQUESTS and request.body:<EOL><INDENT>print('<STR_LIT>')<EOL>try:<EOL><INDENT>print(request.body)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>resp = connection.getresponse()<EOL>status = int(resp.status)<EOL>message = resp.reason<EOL>respheaders = resp.getheaders()<EOL>for i, value in enumerate(respheaders):<EOL><INDENT>respheaders[i] = (value[<NUM_LIT:0>].lower(), value[<NUM_LIT:1>])<EOL><DEDENT>respbody = None<EOL>if resp.length is None:<EOL><INDENT>respbody = resp.read()<EOL><DEDENT>elif resp.length > <NUM_LIT:0>:<EOL><INDENT>respbody = resp.read(resp.length)<EOL><DEDENT>if DEBUG_RESPONSES and respbody:<EOL><INDENT>print('<STR_LIT>')<EOL>try:<EOL><INDENT>print(respbody)<EOL><DEDENT>except:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>response = HTTPResponse(<EOL>status, resp.reason, respheaders, respbody)<EOL>if status == <NUM_LIT>:<EOL><INDENT>new_url = urlparse(dict(headers)['<STR_LIT:location>'])<EOL>request.host = new_url.hostname<EOL>request.path = new_url.path<EOL>request.path, request.query = self._update_request_uri_query(request)<EOL>return self.perform_request(request)<EOL><DEDENT>if status >= <NUM_LIT>:<EOL><INDENT>raise HTTPError(status, message, respheaders, respbody)<EOL><DEDENT>return response<EOL><DEDENT>finally:<EOL><INDENT>connection.close()<EOL><DEDENT>
Sends request to cloud service server and return the response.