示例#1
0
 def __init__(self, address, response):
     self.address = address
     self.host = address[0]
     self.port = address[1]
     self.response = response
     self.description = None
     self.friendly_name = None
     self.type_ = None
     self.base_url = None
     self.services = {}
     self.selected_service = None
     self.document_location = utils.parse_http_header(response, 'Location')
     self._get_description_request(
         utils.parse_http_header(response, 'Location'))
     self._get_friendly_name_request()
     self._get_type_request()
     self._get_base_url_request()
     self._get_services_request()
示例#2
0
def header_filter(device, headers):
    device_contains_header = False

    for header, value in headers.items():
        if utils.parse_http_header(device.response, header) == value:
            device_contains_header = True
        else:
            device_contains_header = False
            break

    return device_contains_header
示例#3
0
    def _get_base_url_request(self):
        location_header_value = utils.parse_http_header(
            self.response, 'Location')
        root = minidom.parseString(self.description)

        try:
            parsed_url = urlparse(
                root.getElementsByTagName('URLBase')[0].firstChild.nodeValue)
            base_url = f'{parsed_url.scheme}://{parsed_url.netloc}'
        except IndexError:
            parsed_url = urlparse(location_header_value)
            base_url = f'{parsed_url.scheme}://{parsed_url.netloc}'

        self.base_url = base_url
        return base_url