<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def poll(self, endpoint, pFormat=PrometheusFormat.PROTOBUF, headers=None):
 """ Polls the metrics from the prometheus metrics endpoint provided. Defaults to the protobuf format, but can use the formats specified by the PrometheusFormat class. Custom headers can be added to the default headers. Returns a valid requests.Response, raise requests.HTTPError if the status code of the requests.Response isn't valid - see response.raise_for_status() The caller needs to close the requests.Response :param endpoint: string url endpoint :param pFormat: the preferred format defined in PrometheusFormat :param headers: extra headers :return: requests.Response """

        if headers is None:
            headers = {}
        if 'accept-encoding' not in headers:
            headers['accept-encoding'] = 'gzip'
        if pFormat == PrometheusFormat.PROTOBUF:
            headers['accept'] = (
                'application/vnd.google.protobuf; ' 'proto=io.prometheus.client.MetricFamily; ' 'encoding=delimited'
            )
        headers.update(self.extra_headers)
        cert = None
        if isinstance(self.ssl_cert, string_types):
            cert = self.ssl_cert
            if isinstance(self.ssl_private_key, string_types):
                cert = (self.ssl_cert, self.ssl_private_key)
        verify = True
        if isinstance(self.ssl_ca_cert, string_types):
            verify = self.ssl_ca_cert
        elif self.ssl_ca_cert is False:
            disable_warnings(InsecureRequestWarning)
            verify = False
        try:
            response = requests.get(
                endpoint, headers=headers, stream=False, timeout=self.prometheus_timeout, cert=cert, verify=verify
            )
        except requests.exceptions.SSLError:
            self.log.error("Invalid SSL settings for requesting {} endpoint".format(endpoint))
            raise
        except IOError:
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"),
                    AgentCheck.CRITICAL,
                    tags=["endpoint:" + endpoint],
                )
            raise
        try:
            response.raise_for_status()
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"), AgentCheck.OK, tags=["endpoint:" + endpoint]
                )
            return response
        except requests.HTTPError:
            response.close()
            if self.health_service_check:
                self._submit_service_check(
                    "{}{}".format(self.NAMESPACE, ".prometheus.health"),
                    AgentCheck.CRITICAL,
                    tags=["endpoint:" + endpoint],
                )
            raise