(self, response)
return result
Parse http api responses.
        We except the following response format:
            - One or more lines with key/value pairs
            OR
            - A single line with a single string value (like 'OK')
Parse http api responses.
        We except the following response format:
            - One or more lines with key/value pairs
            OR
            - A single line with a single string value (like 'OK')
Parse http api responses . We except the following response format : - One or more lines with key / value pairs OR - A single line with a single string value ( like OK )
def _parse_http_api_response(self, response):
        """
        Parse http api responses.
        We except the following response format:
            - One or more lines with key/value pairs
            OR
            - A single line with a single string value (like 'OK')
        """
        result = { 'error' : False }
        
        if not response:
            result['error'] = True
            return result
        
        lines = response.splitlines()
        
        for line in lines:
            if not line:
                """
                Sometimes responses contain empty lines, ignore them
                """
                continue
                
            try:
                key, value = line.split(':', 1)
            except ValueError:
                if '<html>' in line:
                    """
                    The response format is not set yet.
                    """
                    raise PlexMediaBackend.InvalidApiResponseFormatException()
                
                if len(lines) == 1:
                    """
                    The response only contained a single line, with a single value.
                    Wrap it in a response key.
                    """
                    result['response'] = lines[0]
                    return result
                
                """
                The response is invalid, bail out.
                """
                raise Exception('Invalid response item: ', line)    
            
            result[key] = value
        
        if 'Error' in result:
            result['error'] = True
            
        return result
def _parse_http_api_response ( self , response ) : result = { 'error' : False } if not response : result [ 'error' ] = True return result lines = response . splitlines ( ) for line in lines : if not line : """
                Sometimes responses contain empty lines, ignore them
                """ continue try : key , value = line . split ( ':' , 1 ) except ValueError : if '<html>' in line : """
                    The response format is not set yet.
                    """ raise PlexMediaBackend . InvalidApiResponseFormatException ( ) if len ( lines ) == 1 : """
                    The response only contained a single line, with a single value.
                    Wrap it in a response key.
                    """ result [ 'response' ] = lines [ 0 ] return result """
                The response is invalid, bail out.
                """ raise Exception ( 'Invalid response item: ' , line ) result [ key ] = value if 'Error' in result : result [ 'error' ] = True return result